javascript - Google Maps API directionsService.route different ...
文章推薦指數: 80 %
How do I get directionsService to display the route on the map ...
Resultsfromthe2022DeveloperSurveyarehere.
Home
Public
Questions
Tags
Users
Companies
Collectives
ExploreCollectives
Teams
StackOverflowforTeams
–Startcollaboratingandsharingorganizationalknowledge.
CreateafreeTeam
WhyTeams?
Teams
CreatefreeTeam
Collectives™onStackOverflow
Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost.
Learnmore
Teams
Q&Aforwork
Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch.
Learnmore
GoogleMapsAPIdirectionsService.routedifferentfromGoogleMapsDirections
AskQuestion
Asked
6years,9monthsago
Modified
1year,6monthsago
Viewed
26ktimes
10
2
I'musingGoogleMapsJSAPItosearchfornearbyplaces,i.e.restaurantsbasedonmyLatLng:
varrequest={
location:myLocation,
rankBy:google.maps.places.RankBy.DISTANCE,
types:['bar','cafe','food','liquor_store','lodging','meal_delivery','meal_takeaway','night_club','restaurant'],
keyword:['bar','pub']
};
searchService.nearbySearch(request,callback);
IgettheResultsArrayandwanttoshowdirectionstothefirstplacefromthearray:
varrequest={
origin:myLocation,
destination:bars[0].geometry.location,
travelMode:google.maps.TravelMode.WALKING
};
directionsService.route(request,function(response,status){
if(status==google.maps.DirectionsStatus.OK){
directionsDisplay.setDirections(response);
directionsDisplay.setOptions({
suppressMarkers:true
});
varmyRoute=response.routes[0].legs[0];
for(vari=0;i
延伸文章資訊
- 1Directions Service | Maps JavaScript API - Google Developers
Initiating a directions request to the DirectionsService with the route() method requires passing...
- 2一起幫忙解決難題,拯救IT 人的一天
DirectionsRenderer({ map: map }); var directionsService = new google.maps. ... DirectionsService(...
- 3使用Google Map API(Directions Service)獲取及顯示最佳路徑
let directionsService = new google.maps.DirectionsService();let request = { ... directionsService...
- 4Google Maps API V3 : How show the route from point A to ...
The DirectionsService object calculates directions (using a variety of methods of transportation)...
- 5javascript - Google Maps API directionsService.route different ...
How do I get directionsService to display the route on the map ...