Open Marker Info Window based on Lat., Long.

875 views
Skip to first unread message

Mike Wellman

unread,
Jan 25, 2011, 2:16:46 PM1/25/11
to google-map...@googlegroups.com
I have a dropdown menu that fires a function which pushes the lat and long into the function.

I have this working to set the center and zoom but I can't open up the info window that is at the exact lat and long.

map.setCenter(new google.maps.LatLng(one,two));
map.setZoom(12);

Is there anyway to do infoWindow.open and open the info window of those coordinates?

Thanks

Mike Wellman

unread,
Jan 25, 2011, 2:17:28 PM1/25/11
to google-map...@googlegroups.com
Using v3 api

Rossko

unread,
Jan 25, 2011, 2:30:50 PM1/25/11
to Google Maps JavaScript API v3
> Is there anyway to do infoWindow.open and open the info window of those
> coordinates?

http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows

Mike Wellman

unread,
Jan 25, 2011, 2:34:03 PM1/25/11
to google-map...@googlegroups.com
Thank you, but I have read into that functionality.  I don't need to create a marker.  The marker already exists on the map.  I just need to open it's infowindow.

geoco...@gmail.com

unread,
Jan 25, 2011, 3:44:04 PM1/25/11
to Google Maps JavaScript API v3
One option:
Keep track of your markers as you add them to the map. Iterate
through that array checking to see if the distance of the target lat/
lng is less than some small distance (if you are adventurous you can
try equal), if true, trigger the click event on the marker that
matched.

-- Larry

Paulo Fernandes

unread,
Jan 26, 2011, 7:11:25 AM1/26/11
to google-map...@googlegroups.com
have you tried

Rossko

unread,
Jan 26, 2011, 9:24:34 AM1/26/11
to Google Maps JavaScript API v3
> Thank you, but I have read into that functionality.

You seem to have overlooked parts though ;
"To make the info window visible, you need to call the open() method
on the InfoWindow, passing it the Map on which to open, and
optionally, the Marker with which to anchor it. (If no marker is
provided, the info window will open at its position property.)"

So give the infowindow a position in its options, and open it where
you want.

Mike Wellman

unread,
Jan 27, 2011, 2:43:44 AM1/27/11
to google-map...@googlegroups.com
Thanks I found another way of approaching it which worked.  I just placed all the markers/infowindows into an array to keep track of them and called them specifically when needed.

Thank you for the insight and help.

Mike Wellman

unread,
Jan 27, 2011, 2:45:24 AM1/27/11
to google-map...@googlegroups.com
Yes I tried a version of that into an array and it worked that way.  The infowindow.open(map); I had in my code already but I needed to keep track of the markers with the use of an array push.
Reply all
Reply to author
Forward
0 new messages