admin管理员组文章数量:1323035
I need to use the google map directions to show the directions between two addresses.
How can i show the google map using addresses?
Also, I have the source and destination addresses (no latitude and longitude), how can I show the directions between the address using jquery?
I need to use the google map directions to show the directions between two addresses.
How can i show the google map using addresses?
Also, I have the source and destination addresses (no latitude and longitude), how can I show the directions between the address using jquery?
Share Improve this question edited Jul 12, 2010 at 10:51 Daniel Vassallo 345k72 gold badges512 silver badges446 bronze badges asked Jul 12, 2010 at 10:09 PrasadPrasad 59.5k65 gold badges153 silver badges201 bronze badges1 Answer
Reset to default 9That's very easy:
var map = new GMap2(document.getElementById('map_canvas'));
var directions = new GDirections(map);
directions.load('from: London, UK to: Glasgow, UK');
Screenshot:
UPDATE:
Using the v3 API is a bit more verbose, but still straightforward:
var map = new google.maps.Map(document.getElementById('map_canvas'), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
var request = {
origin: 'London, UK',
destination: 'Glasgow, UK',
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
本文标签: javascriptUsing google map GDirections with addressStack Overflow
版权声明:本文标题:javascript - Using google map GDirections with address - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742108112a2421117.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论