I'd like to know how to add bookmarks to the map by clicking on a point in google maps. Actually creating / adding the marker "manually" I already know, what I really wanted was to trigger the function of adding the marker by passing the latitudes and longitudes as a parameter when clicking on the map. Here's what I've done so far:
var mapa;
criarMapa();
function criarMapa() {
var latLng = {lat: -8.063074, lng: -34.871129};
mapa = new google.maps.Map(document.getElementById('mapa'), {
zoom: 18,
center: latLng
});
var marcador = new google.maps.Marker({
position: latLng,
map: mapa
});
}
function adicionarMarcador(latitude, longitude) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: mapa
});
}
Could anyone help me with this?