The Google Maps Javascript API v3 directions service won't do that for you (at least at present). You can add a "dotted" polyline from the ...
OnlydayslefttoRSVP!JoinusSept28atourinauguralconference,everyoneiswelcome.
Home
Public
Questions
Tags
Users
Companies
Collectives
ExploreCollectives
Teams
StackOverflowforTeams
–Startcollaboratingandsharingorganizationalknowledge.
CreateafreeTeam
WhyTeams?
Teams
CreatefreeTeam
Collectives™onStackOverflow
Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost.
LearnmoreaboutCollectives
Teams
Q&Aforwork
Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch.
LearnmoreaboutTeams
GoogleMapsAPIdirectionsService.routedifferentfromGoogleMapsDirections
AskQuestion
Asked
7yearsago
Modified
1year,9monthsago
Viewed
27ktimes
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
Share
Improvethisanswer
Follow
editedDec18,2020at19:51
answeredSep15,2015at22:45
geocodezipgeocodezip
155k1313goldbadges211211silverbadges241241bronzebadges
0
Addacomment
|
3
Thanksforyouranswer@geocodezip,incasesomeoneelseneedsit:
https://developers.google.com/maps/documentation/javascript/examples/overlay-symbol-dashed
services.directions.set.route(request,function(response,status){
if(status==google.maps.DirectionsStatus.OK){
services.directions.display.setDirections(response);
varmyRoute=response.routes[0].legs[0];
varlineSymbol={
path:'M0,-10,1',
strokeOpacity:1,
scale:4
};
varline=newgoogle.maps.Polyline({
path:[myRoute.steps[myRoute.steps.length-1].end_point,to.geometry.location],
strokeOpacity:0,
strokeColor:"#7d7d7d",
icons:[{
icon:lineSymbol,
offset:'0',
repeat:'20px'
}],
map:map
});
}
});
Share
Improvethisanswer
Follow
answeredOct2,2015at16:00
damianbdamianb
14111goldbadge11silverbadge55bronzebadges
0
Addacomment
|
YourAnswer
ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers.
Draftsaved
Draftdiscarded
Signuporlogin
SignupusingGoogle
SignupusingFacebook
SignupusingEmailandPassword
Submit
Postasaguest
Name
Email
Required,butnevershown
PostYourAnswer
Discard
Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy
Nottheansweryou'relookingfor?Browseotherquestionstaggedjavascriptgoogle-mapsgoogle-maps-api-3directionsoraskyourownquestion.
TheOverflowBlog
Fiveninesuptimewithoutdeveloperburnout(Ep.488)
WehateScrumandAgile…whenit’sdonewrong(Ep.489)
FeaturedonMeta
RecentColorContrastChangesandAccessibilityUpdates
Revieweroverboard!Orarequesttoimprovetheonboardingguidancefornew...
ShouldIexplainotherpeople'scode-onlyanswers?
Visitchat
Linked
-1
PreventMapsAPIfromgeocodingcoordinates
0
GMapsAPI-calcroutedrivingintopedestrianarea
Related
7138
HowdoIremoveapropertyfromaJavaScriptobject?
441
GoogleMapsAPIv3:Howtoremoveallmarkers?
315
GoogleMapAPIv3—setboundsandcenter
2468
Getselectedtextfromadrop-downlist(selectbox)usingjQuery
570
HowtodisablemousescrollwheelscalingwithGoogleMapsAPI
3
GoogleMapsV3RouteDestinationMarkEdit
435
LaunchingGoogleMapsDirectionsviaanintentonAndroid
4376
WhydoesGoogleprependwhile(1);totheirJSONresponses?
714
GoogleMapsJSAPIv3-SimpleMultipleMarkerExample
10953
HowcanIremoveaspecificitemfromanarray?
HotNetworkQuestions
Whatarephasedupdates,andwhydoesUbuntuusethem?
CanprofessorsarrangeforanMScscholarshipifyoucontactthembye-mailandtheyareinterestedinworkingwithyou?
CanIgetalatepaymentonmycreditcardifapris0%forthefirst21months?
Whywouldasocietybematriarchalbutpatrilinear?
AsaPhDstudentintheoreticalphysics,whatfractionofmytime(ifany)shouldIspendonbackgroundmaterialratherthanmyresearchproblem?
Howtoaddressteammemberwhoexcessivelydeferstomeandisunwillingtogiveclearfeedback
DoeskillinganapplicationkilltheSQLconnection?
Emailaddressesgivinginternetconnection
CoronatVirtusInCordeMea/VirtueReignsInMyHeart?
CanTempestuousMagicbreakagrapple?
Mastermind:Winintwo
Whatdoyoucallitwhenyouaresayingsomethingpalpablyuntrueonpurpose?
Howisaphrasepatternsubdividedandmeasured?
Whatisthisrhythmgame?
Arrowtoanequalsymbolinaequationtojustifyit
PricingabonddenominatedinUSDbutissuedinEurope
Frenchequivalentoftheidiom'flogadeadhorse'
Asquarenumberthatisaconcatenationofatleast25squares
Howimportantisnetworkingatconferencesreally?
ShouldIallowaPhDstudenttousefiguresofmyUndergraduatedissertationintheirPhDthesis?
Preservingbeefstockconcentrate
Malepluginstalledinwall
PrinteveryFool'sMate
"Kidsthesedays"
morehotquestions
Questionfeed
SubscribetoRSS
Questionfeed
TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader.
lang-js
Yourprivacy
Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy.
Acceptallcookies
Customizesettings