Pan to marker with Javascript

Feb 8, 2012 at 7:10 PM

I had this working in a prior version of your control, but it doesn't seem to work the same in this version. I'm using the map control to show stores. Along side the map is a list of the stores with their information. As the site visitor mouses over the store info (which is in a DIV tag), I want to pan to the store on the map.

So, I need to be able to reference the map markers via Javascript.

How can I accomplish this in version 6?

The old, working script was:

    function doMyPanTo(i) { //lat, lng
    var map = ctl00_content_WhereToBuy_GoogleMap_Map;
    if (map.Markers[i].GMarker != null) {
        var center = map.panTo(map.Markers[i].GMarker.getLatLng());
    } 
    }

 

Thank you,

Shane

Feb 17, 2012 at 6:48 PM

shofestoolusa,

I managed to get this working.

Try this:

maps.mapAppt.map.panTo(maps.mapAppt._behaviors[0].markers[i]);

 

mapAppt is the ID of the map and _behaviors[0] is the reference to the Artem:GoogleMarkers extender.

Please post any improvements.

 

Feb 17, 2012 at 9:10 PM

Thank, fleisch. I'm still having problems. I'm getting a Javascript error that "maps" is not defined. Any thoughts?

Feb 17, 2012 at 9:25 PM

 

"maps" is the Artem namespace.  It really must be there, so I'd say that your javascript should be much lower in the code (not in <HEAD> element) after the namespace has been initialized.  Search for "maps namespace".

Feb 17, 2012 at 9:39 PM

Yeah, my script is already at the very bottom of the page.No luck. Are you using the latest version of the control?

Feb 17, 2012 at 10:33 PM

Yes, v6.  I meant search this forum/discussions for "maps namespace".