right click drop down menu for adding destination on selected route 2 posts by 2 authors in Google Maps

2,435 views
Skip to first unread message

Munna

unread,
Mar 24, 2012, 10:25:18 PM3/24/12
to Google Maps JavaScript API v3
Hi,

I'm trying to write the code to add destination on selected route same
as we do in google maps. When I create a route, I should able to add
destination by right clicking on the path(created using
directionService). Should able to add some additional information
like wait time at that destination and all should be sent to database
for future reference. Also there should be a option to add destination
through input field as well.

That means I want to replicate what you see on google maps home.


Please provide the help/script. I'm looking for this solution on
google for last 1 month. I've posted it on experts-exchange.com &
stackoverflow.com but no luck. Please please please please please help
me..


Thank you.

MymsMan

unread,
Mar 26, 2012, 5:09:54 AM3/26/12
to google-map...@googlegroups.com
I haven't tried it myself but this thread shows a sample right click context menu https://groups.google.com/d/topic/google-maps-js-api-v3/8mfN4FvZ4kk/discussion

Bob

Munna

unread,
Apr 11, 2012, 1:02:35 PM4/11/12
to Google Maps JavaScript API v3
Thank you for your help. But the context menu is not working on route,
elsewhere working. Using this I can't replicate the google maps add
destinations on/outside the selected route.

Please helppppppppppppp

On Mar 26, 2:09 pm, MymsMan <bobbux...@gmail.com> wrote:
> I haven't tried it myself but this thread shows a sample right click
> context menuhttps://groups.google.com/d/topic/google-maps-js-api-v3/8mfN4FvZ4kk/d...

xelawho

unread,
Apr 11, 2012, 2:33:12 PM4/11/12
to Google Maps JavaScript API v3
> Thank you for your help. But the context menu is not working on route,
> elsewhere working. Using this I can't replicate the google maps add
> destinations on/outside the selected route.

don't you just add the location to the waypoints array? maybe a link
to your map and/or a better description of what is "not working" would
help..?

Martin™

unread,
Apr 12, 2012, 2:08:03 AM4/12/12
to Google Maps JavaScript API v3
Look at the source code for the ContextMenu example.

google.maps.event.addListener(map, 'rightclick', function(mouseEvent){
contextMenu.show(mouseEvent.latLng);
});

It's activated by a right click on the Map, a right click on a
Polyline is NOT detected.

Now look at the documentation for the Polyline:

https://developers.google.com/maps/documentation/javascript/reference#Polyline

Look under Events and you will see that a Polyline has a 'rightclick'
event just like the Map.
So you'll want to try something like this:

google.maps.event.addListener(MyPolyline, 'rightclick',
function(mouseEvent){
contextMenu.show(mouseEvent.latLng);
});

Where MyPolyline is a reference to the Polyline drawn by the
DirectionsRenderer.

Martin.

Munna

unread,
May 17, 2012, 12:46:01 AM5/17/12
to google-map...@googlegroups.com
Thank You Martin for your valuable investigation. One concern, ask what I tried/observed is polylines are straight lines connecting markers, but they won't follow the road as direction service do.

Martin™

unread,
May 18, 2012, 3:22:01 AM5/18/12
to Google Maps JavaScript API v3
If i understand you correctly then just disregard my comment "Where
MyPolyline is a reference to the Polyline drawn by the
DirectionsRenderer."

Just add the event listener to the straight polyline and it should
work as desired.

Martin.

On May 17, 5:46 am, Munna <jaiswalsail...@gmail.com> wrote:
> Thank You Martin for your valuable investigation. One concern, ask what I
> tried/observed is polylines are straight lines connecting markers, but they
> won't follow the road as direction service do.
>
>
>
>
>
>
>
> On Thursday, April 12, 2012 11:38:03 AM UTC+5:30, Martin™ wrote:
>
> > Look at the source code for the ContextMenu example.
>
> > google.maps.event.addListener(map, 'rightclick', function(mouseEvent){
> >         contextMenu.show(mouseEvent.latLng);
> > });
>
> > It's activated by a right click on the Map, a right click on a
> > Polyline is NOT detected.
>
> > Now look at the documentation for the Polyline:
>
> >https://developers.google.com/maps/documentation/javascript/reference...

Tony Montana

unread,
Jul 12, 2012, 11:12:28 AM7/12/12
to google-map...@googlegroups.com
Hu Munna,


Did you find a solution to this, I also need a add multiple destinations to a map, along with changing the destination marker for each waypoint.


Thanks

Tony Montana

unread,
Jul 12, 2012, 11:18:12 AM7/12/12
to google-map...@googlegroups.com
Hi Mannu,

Actually I think i've got a solution, will put it up on stack overflow when I implement it.

Thanks
Reply all
Reply to author
Forward
0 new messages