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 Google ...
Home
Categories
Questions
InterviewQuestions
Contact
Search
Search
Home
Categories
Questions
InterviewQuestions
Contact
Search
12May2015
MudassarKhan
5
Comments
47187 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"12":"GEO&GMAP(定點導航)" - iT 邦幫忙
另一個是在基本map中沒有的,則是下列.. var directionsDisplay = new google.maps.DirectionsRenderer({ map: map }); v...
- 2Google Maps API directionsService.route different from ...
The Google Maps Javascript API v3 directions service won't do that for you (at least at present)....
- 3Google Maps API Directions Service Example - SoftAuthor
The Directions Service is a client-side JavaScript libraray that lets us to get directions data b...
- 4使用Google Map API(Directions Service)獲取及顯示最佳路徑
之前文章有介紹過如何使用Google Map API(Geocoding API, Distance Matrix Service)去取得點位縣市鄉鎮資訊或是兩點之間的距離及移動所需時間資訊(有...
- 5Google map - gists · GitHub
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);;. var directionsServ...