[SOLVED] Zooming in Google Map only works once.

Answered
0
0

I have a function that is called on a button click.  The first time you call it , it zooms in to zoom factor 16. If you zoom out manually after that, subsequent calls do not zoom in, however it does re-center the map each time.

I’m not sure if this recently stopped working… I am on 1.5.49.

Thanks.

 

Public Sub ZoomInLocation(ByVal intZoomLevel As Integer, Optional ByVal sngLat As Single = 0.0, Optional ByVal sngLon As Single = 0.0)
If sngLat = 0 Then
sngLat = Me.sngLastLat ‘coordinates not specified
sngLon = Me.sngLastLon
Else
‘coordinates specified: ‘use parameters passed in
End If

Dim sngFudgeFactor As Single = intZoomLevel * 0.00007 ‘0.00006 works on zoomlevel 16 in the US quadrant.
mobjGoogleMap.CenterMap(sngLat – sngFudgeFactor, sngLon)
SetCoordinates(sngLat – sngFudgeFactor, sngLon)
mobjGoogleMap.Options.zoom = intZoomLevel
mobjGoogleMap.Update()
Application.Update(Me)
End Sub

  • You must to post comments
Great Answer
0
0

The Widget.Options object is the initialization JSON object. Changing it’s properties doesn’t update the widget. It depends on the the widget and the integration. Most javascript widgets cannot update their initial configuration and have either specific methods or need to be destroyed and recreated.

Also, when interacting with the widget, it doesn’t update the options. The configuration options and the widget behavior can be very different.

It works the first time because Wisej (both client and server side) only update the differences.

In this case, you can handle the MapPropertyChanged event to receive updates from the google map widget:

 private void MobjGoogleMap_MapPropertyChanged(object sender, Wisej.Web.Ext.GoogleMaps.MapPropertyChangedEventArgs e)
 {
    if (e.Name == "zoom")
       mobjGoogleMap.Options.zoom = (int)e.Value; // in case you want to keep track like this, or use a different variable.
 }

To update the zoom level on the client use:
mobjGoogleMap.Call("this.map.setZoom", 16);


The method to call to update a property depends on the widget.

 

 

  • Andrew Niese
    That makes sense why it only worked the first time. Using MapPropertyChanged I can be sure that the Options.zoom matches what is actually shown on the client. Adding the call to this.map.setZoom in my ZoomInLocation() function seems to have resolved the issue. Thanks.
  • You must to post comments
0
0

Levie, to make your sample reproduce the bug, call the ZoomInLocation function with a fixed zoom level, like 16.

1. Click button (notice what “zoom level 16” looks like)

2. Zoom out several levels

3. Click button again —> zoom goes maybe 1-2 levels, not to “zoom level 16”

Your original code didn’t show the bug, but my modifications made the error. Also I pass in the “fudged” new latitude, just like my sample code, but that didn’t make the difference.

 

 

 

 

 

  • You must to post comments
0
0

I cannot open the sample.

 

 

  • Levie (ITG)
    Hi Andrew, This is because the dll files are missing. Please add references to “Wisej.Core.dll”, “Wisej.Web.dll”, and “Wisej.Web.Ext.GoogleMaps” from “C:\Program Files\IceTeaGroup\Wisej\bin” (or your default location) inside the “References” tab of the project. If there are any existing Wisej references, delete them and re-add them. Let me know if that works to build the project! Best, Levie
  • You must to post comments
0
0

Hi Andrew,

I am not able to replicate the zooming problem.  Please try out the attached sample with your API key and DLL’s and see if it works for you…  It zooms in and out fine, even after manually changing the map zoom.

If you are still having issues could you please attach a demo with detailed instructions on how to reproduce the error?

Best regards,

Levie

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.