Google Maps API V3: DirectionsService (Driving Directions ...
文章推薦指數: 80 %
Here Mudassar Ahmed Khan has explained with example and attached source code, how to use the Google Maps API V3 to plot driving directions and route on ...
Home
Categories
Questions
InterviewQuestions
Contact
Search
Search
Home
Categories
Questions
InterviewQuestions
Contact
Search
12May2015
MudassarKhan
5
Comments
44405 Views
Google
HereMudassarAhmedKhanhasexplainedwithexampleandattachedsourcecode,howtousetheGoogleMapsAPIV3toplotdrivingdirectionsandrouteonGoogleMapsusingtheDirectionsService.
Download
ViewDemo
DownloadFreeWord/PDF/ExcelAPI
DownloadFreeWord/PDF/ExcelAPI
InthisarticleIwillexplainwithexampleandattachedsourcecode,howtousetheGoogleMapsAPIV3toplotdrivingdirectionsandrouteonGoogleMapsusingtheDirectionsService.
HTMLMarkup
TheHTMLMarkupconsistsoftwoTextBoxesfirstoneforenteringSourceaddresswhiletheotherforenteringdestinationaddress,aButtonandthreeHTMLDIVsfordisplayingthedistanceanddurationdetails,plottingmapanddisplayingdirections.
CalculateDistance,TravelDuration,draw(plot)RouteanddisplayDirections
usingDirectionsService
InsidetheGoogleMapswindowloadeventhandler,forthesourceandthedestinationTextBoxesIhaveimplementedGooglePlacesAutocompleteTextBox.FormoredetailspleasereferImplementGooglePlacesAutocompleteTextBox.
WhentheButtonisclicked,firsttheMapandtheDirectionsserviceisinitializedtodisplaythemapandthedirectionsintheirrespectiveHTMLDIVs.
ThenusingthesourceanddestinationaddressesfromtherespectiveTextBoxes,thedetailsofthedirections,route,distanceanddurationaredisplayedinsidetherespectiveHTMLDIVs.
";
dvDistance.innerHTML+="Duration:"+duration;
}else{
alert("Unabletofindthedistanceviaroad.");
}
});
}
Screenshot
Demo
ViewDemo
Downloads
GoogleMaps_CalculateDistance.zip
DownloadFreeWord/PDF/ExcelAPI
RelatedArticles
Previous
Next
Nocommentshavebeenaddedtothisarticle.
AddComments
Thankyouforthefeedback.Thecommentisnowawaitingmoderation.Youwillbenotifiedviaemailwhentheauthorrepliestoyourcomment.
Pleaseselectacommenttoreply
Youcanaddyourcommentaboutthisarticleusingtheformbelow.Makesureyouprovideavalidemailaddresselseyouwon'tbenotifiedwhentheauthorrepliestoyourcommentPleasenotethatallcommentsaremoderatedandwillbedeletediftheyareNotrelavanttothearticleSpamAdvertisingcampaignsorlinkstoothersitesAbusivecontent.Pleasedonotpostcode,scriptsorsnippets.
Name
Email
Comment
Securitycode:
Invalidsecuritycode.
Ideclare,Iacceptthesite's
PrivacyPolicy.
AddComment
OurSupportTeamisheretohelp.
AskQuestion
Disclaimer:ThecodesamplesandAPIavailableatwww.aspsnippets.comareavailableabsolutelyfree.
Youarefreetouseitforcommercialaswellasnon-commercialuseatyourownrisk,butyoucannotuseitforpostingonblogsorothertutorialwebsitessimilartowww.aspsnippets.comwithoutgivingreferencelinktotheoriginalarticle.
AllthecodesamplesandAPIprovidedbytheauthorsaresolelytheircreationandneithertheauthornorthesiteareresponsibleifitdoesnotworkasintended.
Iagreetotheaboveterms.
Download
Required
ViewDemo
Whatourreaderssay
Previous
Next
©
2022
www.aspsnippets.com
Allrightsreserved|PrivacyPolicy
|PoweredbyExcelasoftSolutions
ThissitemakesuseofCookies.PleasereferPrivacyPolicyformoredetails.
Gotit
延伸文章資訊
- 1一起幫忙解決難題,拯救IT 人的一天
DirectionsRenderer({ map: map }); var directionsService = new google.maps. ... DirectionsService(...
- 2Google Maps API Directions Service Example - SoftAuthor
Create an instance of the DirectionsService Object. ... Call the route() method on the directions...
- 3javascript - Google Maps API directionsService.route different ...
How do I get directionsService to display the route on the map ...
- 4Directions Service | Maps JavaScript API - Google Developers
Initiating a directions request to the DirectionsService with the route() method requires passing...
- 5Google map - gists · GitHub
directionsService.route(request, function(response, status) {. if (status == google.maps.Directio...