With GMaps.js you can add markers this way:
map.addMarker({ lat: -12.043333, lng: -77.028333, title: 'Lima', click: function(e){ alert('You clicked in this marker'); } });
latitude and longitude are required. You can also attach additional information with details
, which will be passed to Event object (e
) in the events previously defined.
Note If you want to show an Info Window, you must add:
infoWindow: { content: '<p>HTML Content</p>' }
NoteThe Info Windows also can bind these events: closeclick
, content_changed
, domready
, position_changed
and zindex_changed