Reading GoogleMap zoom level

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
Answered
0
0

Hi, I’m converting a map application from VWG to WiseJ. In VWG, you could read the .MapZoomLevel property — is it possible to read the current zoom level in WiseJ?

I can set it by calling Me.mobjGoogleMap.Options.zoom = 19, but if I check the Options.Zoom value, I get System.MissingMemberException : Public member ‘zoom’ on type ‘DynamicObject’ not found.

 

‘Only zoom and redraw if necessary.
If Me.mobjGoogleMap.Options.zoom <> 19 Then
Me.mobjGoogleMap.Options.zoom = 19 ‘ high zoom level
Me.mobjGoogleMap.Update()
End If

  • You must to post comments
Best Answer
0
0

Hi Andrew,

The GoogleMaps extension allows you to read/set any property in the google maps widget without having to map them to a specific C# property, this gives you maximum flexibility with the google maps oobject. The Options object is a Wisej DynamicObject which is basically identical to a JavaScript object but on the server.

However, such a dynamic object doesn’t have any of the initial values unless you initialize those values. When you try to read the zoom property before it’s initialized it simply doesn’t exist. You can check if it exists by comparing to null (or Nothing in VB) or by using the null operators, in VB it’s the If expression: If (nullable, valueIfNull), or  in C# var zoom = Options.zoom ?? 4. In VB.BET Dim zoom as If (Options.zoom, 4) (or something like this).

Another way is to simply set the initial options on your google maps object including the zoom, like the example linked below.

You can also detect live when a property is changed by the user by attaching to MapPropertyChanged event. The event args carry the property name and the new value. I tried the example we have online (https://wisej.com/examples/) and when I zoom the map I get the MapPropertyChanged event and I can also read the new zoom value like this: this.googleMap.Options.zoom.

HTH

Best,

Luca

  • You must to post comments
0
0

Thanks for the info, Luca.  I’ll keep experimenting with the extension.

  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json