![]() ![]() ![]() If these options still don't suit you then you will need to mix your map with traffic data from third-parties. Using only Google Maps APIs and Services, this is as far as you can go. Overlay maps do not affect route calculation. Yandex Traffic covers only some countries in Eastern Europe ( wiki, in Russian), we need layers for other countries too. You can read more about JavaScript Directions Service at This is still not what I want For (just) displaying traffic one can use OsmAnd overlay/underlay maps in the configure map settings. The Heatmap layer renders geographic data using a Heatmap visualization. You can use the Data layer to store your custom data, or to display GeoJSON data on a Google map. So if you make a request for alternative routes and have a departureTime you will have a duration_in_traffic in the reponse for each route, and with it you can draw the polygon with the colour you want depending on how good or bad the path is. Satellite:Aerial pictures Point to Layers and click Moreto find info about: Terrain:Local terrain Traffic:Local traffic conditions Transit:Bus, subway, and rail routes Biking: Bike paths. The Maps JavaScript API has several types of layers: The Google Maps Data layer provides a container for arbitrary geospatial data. Time in traffic (duration_in_traffic) in the response. (.)įor Google Maps APIs Premium Plan customers, if you include theĭepartureTime in the request, the API returns the best route given theĮxpected traffic conditions at the time, and includes the predicted Valid) specifies the desired time of departure as a Date object. With this Service, you can make a request with provideRouteAlternatives set to true and a departureTime set for drivingOptions.ĭepartureTime (required for the drivingOptions object literal to be Using Firebug I do not see any errors but the traffic layer does not toggle. I found this post: Adding Custom Control to Google Map (Adding toggle for traffic layer) I have tried putting the DOM listener into various places in my code to no effect. The Directions Service which caluculates the directions between two points. 1 I want to toggle the Google Maps traffic layer. ![]() If this solution is not good for you, there is another way. This however also means that you can't simply pick a part of the layer (say, the one matching your polyline) and paste it there - that is not the purpose of layers. Thus Traffic layers are a good solution to avoid the previous behavior. I have gotten the below script from the internet with some fine tuning, but I cannot figure out how to get the control into the map. This is not exactly what I wantĮxperience usualy tells us that when you are suggesting a route to a user, if the said route has a red traffic line the user will automatically search for something else - forcing him to do another query would be cumbersome. I am trying to add the Google Maps Traffic Layer with a control, and since I am so new with this, I cannot figure it out. PS: before using it make sure you use your API KEY in įor more information about this example you can read the documentation page regarding this example or the full documentation for displaying data (which i recomemend). Simply displaying the traffic layer can be done using the JavaScript API like the following function initMap() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |