[Google Maps Mobile] Google Map Mobile on marker click 

[Google Maps Mobile] Google Map Mobile on marker click 

  
Forge Component
(2)
Published on 6 Oct by OutSystems Labs
2 votes
Published on 6 Oct by OutSystems Labs

Hi


I'm new with outsystem maybe anyone can help me how to add a marker click event for google map mobile


>>


I tried to get the idea from your sample but nothing happen , Hopefully you can please explain more. right now im trying to open the infowindow . 

Hmm, did you check Henrique's reply, as well? He explained it in better detail, but you need to basically:

  1. Append the event Static Entity entries to a list (for example, "click" or "dragstart"), that will be passed to the map on the "MarkerEvents" input parameter
  2. Add an event listener to the "MarkerRaisedEvent" event from the Map block with the logic you need to run on Marker events (see this for a more visual aid)

If you're sure you did these steps, could you ensure you have the latest version of Google Maps Mobile installed? And if your references to it are refreshed?

(for everyone else wondering, this thread is a follow-up to this one)

Carlos Simões wrote:

Hmm, did you check Henrique's reply, as well? He explained it in better detail, but you need to basically:

  1. Append the event Static Entity entries to a list (for example, "click" or "dragstart"), that will be passed to the map on the "MarkerEvents" input parameter
  2. Add an event listener to the "MarkerRaisedEvent" event from the Map block with the logic you need to run on Marker events (see this for a more visual aid)

If you're sure you did these steps, could you ensure you have the latest version of Google Maps Mobile installed? And if your references to it are refreshed?

(for everyone else wondering, this thread is a follow-up to this one)

Hi Carlos, can you provide sample event listeners that i should put on js. I have tried a couple of samples from google maps API doc but i cant make it work. I was able to get the markerId, mapId, and eventName, I need to be able to get the coordinates upon clicking the marker. a sample code would really help a lot. thanks in advance!  

 


Ok, guys, I'll spoil it for you   

You probably don't know it, but Google Maps Mobile has the same JS API as the old Google Maps, which means you can access JS objects for maps, markers and directions currently in use.

Within this object, you can access the respective Google Maps JS API object and use Google's API methods on it. Here's the handler from the above example updated to obtain the coordinates and write them to the console:

console.log("Marker '"+$parameters.MarkerId+"' on map '"+$parameters.MapId+"' received event '"+$parameters.EventName+"'");

// Obtain the ACTUAL Google Maps Marker...
var actualGoogleMarker = osGoogleMap.getMap($parameters.MapId).getMarker($parameters.MarkerId).gMarker;

// ...and its position, using the Google Maps JS API
var position = actualGoogleMarker.getPosition();
console.log("Its coordinates are "+position.lat()+", "+position.lng()+".");

You can use the osGoogleMap object to access our JS API. You should be able to port most click handlers used with the old component; and even regular Google Maps examples should be easily ported, if you have the respective Map and Marker ids.

Hope this helps!

Feel free to ask any questions you might have! :)

Best regards,

Carlos Simões