B4J Question how to make gmap polygons not clickable

Starchild

Active Member
Licensed User
Longtime User
As many previous postings on B4X have asked, I am trying to make the polygons (and other google map shapes) NOT CLICKABLE. I need to be able to get the actual lat/lng coordinates to be returned via the gmap events. The current jGoogleMaps library provides no option for managing whether (or not) a shape is click sensitive and thus, the shape generates its own event with only a reference to the shape clicked. the map point within the shape (actual lat/lng of the click) is never returned.

I have browsed the internet for possible solutions.

First possibility, if it was possible, make a change to the shape constructor declaration (inside library) to set the shape property "Clickable: false".
As in this ref.
https://stackoverflow.com/questions/2865351/clicking-inside-a-polygon-in-google-maps

Second possibility, if the object reference for the "event Listener" allocated for the specific shape was returned then the listener could be removed after the shape is created.
As used in this ref which temporarily replaces an event handler.
http://rterp.github.io/GMapsFX/apid...en/gmapsfx/javascript/event/package-tree.html
This provides the best functionality as the programmer can choose when to make a shape clickable or not at runtime.

Third possibility, create my own transparent VIEW (say a label) and place it over the top of the displayed gmap view. When my view is clicked I can take the X/Y screen coordinates and scale them back to a lat/lng coordinate using the gmap.bounds function. This is a little tricky as the earth's curvature needs to be considered when large areas are being displayed, but still possible to achieve. The problem with this is, I can't get my label view to pass-through the click or other mouse events which prevents the normal mouse control functuality provided by google maps object. So I would need to manage this (scroll/pan/zoom/pinch etc) myself and drive the gmap object pragmatically.

I would rather get the First or second possibilities working.
I believe the event handler object is
com.lynden.gmapsfx.javascript.event.UIEventHandler

I am not sure where to go next with this.

The first possibility is not possible unless I can create my own gmap shape pragmatically, not using the jGoogleMaps library, or the jGoogleMaps library provides another way to initialise the shape objects with clickable= false.

The second possibity, is not possibly without a reference to the listener object for the shape.

And YES, I am currently working on the third solution, as it's the only one I can current achieve.
I think a proper solution targeting the actual gmap shape objects would be best.

Does any one else have any thoughts or code snippets they would like to share?
 

Starchild

Active Member
Licensed User
Longtime User
Thanks for the library update
V1.75 - Polygons, Polylines and Circles are only clickable if the relevant click event is handled.

An interesting solution.

It provides me with most of what I needed.
Although, as I want to pragmatically enable and disable the clickable nature of a polygon at different times within my mapping program, the declaration of the return event is not selectable at runtime.

If I keep two gmap objects overlayed on top of each other and use their (asPane.Visible) property to inversely manage which one is visible on screen, I can have all polygons clickable or not clickable. Unfortunately I can't make just one polygon clickable at a time.

To give individual polygon event control I understand that the polygon's own Listener would need to be Removed and Added when needed. "Considerably more complicated" and not possible without a listener reference.

Anyway, I did not expect a library update so quickly.
I thank you for this improvement.
 
Upvote 0
Top