开发者

How to get road hazards using Google Maps API / Directions API

开发者 https://www.devze.com 2023-03-08 21:47 出处:网络
I am开发者_如何学JAVA trying to draw a map with the traffic layer and display road conditions (constructions, accidents, etc.) Using the Google Maps API / Google Directions API, how can I obtain a ref

I am开发者_如何学JAVA trying to draw a map with the traffic layer and display road conditions (constructions, accidents, etc.) Using the Google Maps API / Google Directions API, how can I obtain a reference to the traffic conditions that are displayed, or more specifcally, the conditions along a path / route? Thank you.


In Google Maps API v3, the documentation says you display traffic conditions like this:

var myLatlng = new google.maps.LatLng(34.04924594193164, -118.24104309082031);
var myOptions = {
  zoom: 13,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);

I don't think this will display specific hazards (like accidents or construction) but simply slow traffic. You would almost certainly have to get such data from a source that wasn't Google Maps.

This question was tagged as both Google Maps API v3 (which is what I answered with above) and Android. I don't know if this helps you for Android native programming, but hopefully it's not useless. (Update: Looks like the question has now been retagged to remove the API v3 tag.)

0

精彩评论

暂无评论...
验证码 换一张
取 消