detecting Google Map center change

0
0

If a user pans/moves to a different location in my GoogleMap, and I want to change to a Satellite View by updating GoogleMap.Options:

Me.mobjGoogleMap.Options.mapTypeId = “satellite”
Me.mobjGoogleMap.Update()

It reloads the map options, and goes back to the original “center”.

This is annoying because I don’t want them to lose their place.

I thought it would automatically update the Options.Center property when moving the map location, but this isn’t true.

 

How can I detect when the user pans the map location, and update center accordingly?

the MapPropertyChanged event does not seem to update for panning/moving, but it does fire when the zoom level is changed.

Should WiseJ implement this method? https://developers.google.com/maps/documentation/javascript/reference/3/map#Map.getCenter

and will it return the “current” center or the original one?

 

thanks,

Andrew

 

 

 

  • You must to post comments
0
0

OK, I figured out that I need to pass the WiseJ GoogleMap widget into external Javascript, because “Google doesn’t provide any way to retrieve a map from an id or an element.” (Luca 4/27/18)

External Javascript:

//pass in a WiseJ googlemap object. call getbounds on it and return value
function getMapBounds(googleMap) {
var map = googleMap.map;
return map.getBounds();
}

 

.NET

”Call gmapHelper javascript, function getMapBounds. Pass in our GoogleMap WiseJ widget, have a callback that can access the return value.
Application.Call(“window.getMapBounds”, Sub(a As Object)
AlertBox.Show(a.ToString)

End Sub, Me.mobjGoogleMap)

 

I imagine I can do the same thing with .getCenter() , and I’ll have to detect when it might be updated by some other event than MapPropertyChanged().

So I think this might be sufficient, but I definitely appreciate you guys updating and continuing to improve the WiseJ GoogleMap component so it is as useful as possible

 

–Andrew

  • You must to post comments
0
0

On another note, it would also be useful to know the boundary of the map viewport at any given point in time.  This can be done in Javascript by calling map.getBounds()

Question is, what’s the best way to make use of that server side?

I know how to call it in an external JavaScript file, and then pass the value back in a WebMethod, but that would be a somewhat sloppy way of doing it as it would interrupt the flow of code.

Should I use a Javascript extender , with callback Action(Of Object) like

mobjGoogleMap.Call(“this.getBounds()”, Sub()
(somehow receive the LatLng result object here?)
End Sub)

 

I tried this and got a stack overflow.
mobjGoogleMap.Call(“this.getBounds()”, Sub(latLngAs Object)
AlertBox.Show(a.ToString)

End Sub)

 

 

thanks for bearing with me.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.