Google Maps Marker Events

Hi, new user and first post so go easy on me :smiley: Loving Wappler, finally get to realise my ideas, done more in a few weeks than I could have imagined but now I am stuck.

I have google maps and dynamic markers working fine, what I need to be able to do is to click the marker on the map and run a serverconnect in the client using the ID of the marker that was clicked so that I can update another column with information.

I have read the forums and from what I understand there is no event available in wappler when a marker on a google maps is clicked. My knowledge of javascript is poor but I can cut and paste really well :slight_smile: so I have been trying to utilise Googles own event listener on click but I cannot figure out how to get a reference to the markers from wappler to pass to the function or if this is even possible.

addListener(marker, ‘click’, function (){
do stuff}

I followed some of the other examples posted in the forums and I have lines and polygons working which use google code and references wappler google maps but I am at a loss with markers.

I feel like the data is there but I just can’t get access to it, I have tried using the “markers” variable that is created by wappler but to no avail.

dmx-bind:markers=“SC_asset.data.asset_query” marker-id=“ASS_id”

Any help appreciated even if its “no you can’t do it” or “you need to use Google API’s only”

Many thanks, Paul

Welcome Paul!

It’s possible that your attempt to add the listener is happening before the markers have been added too the DOM—basically app connect hasn’t finished loading everything.

Try wrapping your code in the following and experiment again with how to reference the marker (I haven’t used that so can’t help there).

	<script>
		$( document ).ready(function() {
            // your javascript here
        });
	
	</script>

—Ken

Hi Ken

Thank you for the suggestion, I used it to do some more experimentation using console.log without any luck

I thought I could have referenced the bindings that are used to setup the map but not sure if I am doing this right.

dmx-google-maps id=“maps1” dmx-bind:markers=“SC_asset.data.asset_query” marker-id=“ASS_id” marker-latitude=“ASS_lat” marker-longitude=“ASS_lon”

console.log(dmx.parse(‘markers’)); is NULL
console.log(dmx.parse(‘maps1’)); shows the map object but doesn’t contain any references to marker
console.log(dmx.parse(‘marker-id’)); = 0 as does any other value such as marker-lattitude

I think the marker data is not exposed by DMX google map function but tbh I haven’t a clue.

Thanks for your help though, Paul