How to set AddMarkerEvent Handler for Google Map

I have a local variable "Address" which is a combination of street pincode and city. I want to add a marker to the address provided by the user in the input in the form mentioned above. I am confused as to how to set the handler of AddMarkerEvent so that it can add marker on the map for the specified address.

Hi Shrushti,

to add the marker on the map, you don't need the AddMarkerEvent, only the AddAddressMarkerToMap.  

The AddMarkerEvent is for attaching an event to be triggered when the marker is clicked.

You do need to make sure the map is redrawn after the AddAddressMarkerToMap : in a traditional web application, there is the refresh action for that, in a reactive web application, I would expect the map automatically reacts to the change, and redraws itself without you having to do anything.

Dorine

Hi Dorine,

I had previously used only AddAddressMarker but it did not work. It didn't add marker to the map. I am doing this on Mobile application can you suggest what changes do I need to make?


This is how the screen looks like and clicking on "add marker" it goes to the client action I had mentioned above. 


Ok,

i haven't used it in mobile yet, but another thing that has to happen is that the map has te be centered around the new marker for it to be visible, right ?  

So when you move the map to the right location, do you see the marker ?  That's a first thing to check.  

If that is oke, it's a matter of centering the map.  In traditional web app, there are the CreateBounds/AddMarkerToBounds/FitMapToBounds actions to make sure the map shows all your markers.  Don't know about the Mobile version ???

And if there is only one marker at any given time, there als the AddressToCoordinates + the CenterMap you could use.

Dorine


AddressToCoordinates outputs longitude and latitude of the address which is used by CenterMap. In my case the Lat and long are returned as -1 -1 resp and not the exact lat long of the address. 



Well,

I have only ever used Google Maps with long and lat.  

I guess, when you want to use it with an address, you have to cater for the situation that the given address just doesn't ring a bell for the component.  Have you tried with other adresses ?

Yes, tried with couple of addresses.

Ok,

Please share your oml, maybe there is some detail wrong in how you pass the adressen, or something.

Also, you are testing this on a mobile or in a browser ?

Hi, 

I am trying it in browser. And I am passing the address in this form...

Hi Shruti,

if you share your oml, someone can take a look at exactly what you are doing.

what exact component are you using?

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.