B4J Question GoogleMaps Polygon properties

klaus

Expert
Licensed User
Longtime User
When we define a polygon in GoogleMaps and click on it, we get in the Click event routine a MapPolygon object.
How can we get it's properties, paths, vertices , colors etc. and methods RemoveAt, InsertAt etc.
Currently, only Visible is available.
The same for Polyline.
Will these properties be added in the future?
Can these be managed with JavaObjects?
 
I found the solution with JavaObject.
Below a code snippet:
Code:
Private Sub gmap_PolygonClick (SelectedPolygon As MapPolygon)
   Private joPoint, joPath As JavaObject
   CurrentDrawObjcet = CurrentDrawObjcet.InitializeNewInstance("com.lynden.gmapsfx.shapes.Polygon", Null)
   CurrentDrawObjcet = SelectedPolygon
 
   joPath = joPath.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.MVCArray", Null)
   joPath = CurrentDrawObjcet.RunMethod("getPath", Null)
 
   ckbDraggable.Checked = CurrentDrawObjcet.RunMethod("getDraggable", Null)
   ckbEditable.Checked = CurrentDrawObjcet.RunMethod("getEditable", Null)

   Private i As Int
   Private Size As Double = joPath.RunMethod("getLength", Null)
   ltvPoints.Items.Clear
   For i = 0 To Size - 1
     joPoint = joPath.RunMethod("getAt", Array As Object (i))
     Private ll As LatLng = joPoint.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array(joPoint))
     ltvPoints.Items.Add("Lat" & i & "= " & NumberFormat(ll.Latitude, 1, 6))
     ltvPoints.Items.Add("Lng" & i & "= " & NumberFormat(ll.Longitude, 1, 6))
   Next
 
   pnlDrawing.Visible = True
End Sub
 
Last edited:
Upvote 0
Today i wanted to show the coordinates from a clicked polygon and used your code - but i got the same values for each point.
Now i looked deeper in your sample and found the problem: i think it should be
Code:
For i = 0 To Size - 1
     joPoint = joPath.RunMethod("getAt", Array As Object (i))
instead of
Code:
For i = 0 To Size - 1
     joPoint = joPath.RunMethod("getAt", Array As Object (0))

Finaly i want to thank you for this sample; its currently very usefull for me!
 
Upvote 0
Back
Top