PanTo Marker or Location

Mar 31, 2008 at 10:53 PM
The Google Maps API provides a javascript method for panning (panTo). Is there a way to implement this functionality through the GoogleMap Control?
Coordinator
Apr 1, 2008 at 6:02 AM
Sure,
GoogleMap has next methods: PanTo, PanBy and PanDirection.
The idea of those methods is to fire from server code a client-side action.
Means that you can fire on postback for some cases from server code those API functions to be invoked for the map.

If you don't want to make a postback to server, then I have wrapped those function in a GoogleMap control JS model and you can call them from your client-side code.
So, let's say you have a GoogleMap control on the page with ID="GoogleMap1".
GooleMap control has a property ClientMapID, which keeps the name map instance.
Then here is an exemple of how you can call panTo from JS function:
function doMyPanTo(point) {
    var map = <%= GoogleMap1.ClientMapID %>;
    map.panTo(point);
}
, where point is of type GLatLng.

Hope this helps.
Regards
Apr 2, 2008 at 1:06 AM
Thanks, velio.

I think you left the ._gmap off of the map var but I figured that out.
Coordinator
Apr 2, 2008 at 6:04 AM
Edited Apr 2, 2008 at 6:09 AM
Hi,
I have wrapped some of the methods of original Google Map.
So, now you can use it as I gave in the example above.
Have in mind I have changed the name of the original Google Map reference inside Artem.Web.GoogleMap javascript class.
You should reference it now with GMap instead _gmap.
This means you can change the example above like this:
function doMyPanTo(point) {
    var map = <%= GoogleMap1.ClientMapID %>;
    map.GMap.panTo(point);
}

Same pattern is use for all other object.
For example you can reference in JS the original Google Map marker in Artem.Web.GoogleMarker through GMarker
For example let's say you have a GoogleMap control with ID="GoogleMap1" and more than one marker on it, then here is how you can hide the first one from you JS code:
function hideFirstMarker() {
    var map = <%= GoogleMap1.ClientMapID %>;
    map.Markers[0].hide();
}
or
function hideFirstMarker() {
    var map = <%= GoogleMap1.ClientMapID %>;
    map.Markers[0].GMarker.hide();
}

So, be awared of that.
Hope this helps

Regards