Google Maps Marker Web Open in Google Maps

Google Maps Marker Web Open in Google Maps

  

Hi,

I have successfully created several markers on google maps using GMaps API.

But now i want to open google maps web when i click on a marker.

I also need smart zoom level to optimize the zoom to show all markers on the map.


Can you help?

Thank you.

Hi Pedro,

Regarding your first question, in order to associate a specific url to a marker and open it when clicking in that marker you can follow the steps bellow:

  1.  Add the url in the MarkerOptions input of the actions AddAddressMarkerToMap or AddCoordinateMarkerToMap:
  2. Add an event for that marker by using the AddMarkerEvent action with "click" as the TriggeringEvent and in the Handler add a javascript line to open a window with the url that was set:
    • Example
      "function() {
          ...
          window.open(this.url);
      }"


As for the second question, to adjust the zoom to show all markers, you should first "set a boundary" by using the action AddMarkerToBounds for every marker you wish to include in that zoom level. Then, in order to readjust the zoom level, you can simply use the action FitMapToBounds.

Hope it helps. Best Regards,

Luís