1
I am using the code below to add several markers to the map. Each click a marker is added. In Chrome the code works perfectly, however, when generating code using Cordova the map is displayed but no marker is added.
function initialize() {
var inicial = { lat: -22.4086028, lng: -43.6624047 };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: inicial
});
google.maps.event.addListener(map, 'mousedown', function(event) {
var initPoint = {x: event.pageX, y: event.pageY},
toBeCanceled = false,
latLong = event.latLong;
google.maps.event.addListener(map, 'mousemove', function(event) {
var newPoint = {x: event.pageX, y: event.pageY};
toBeCanceled = true
});
google.maps.event.addListener(map, 'mouseup', function(event) {
if (toBeCanceled) {
event.stop()
} else {
addMarker(event.latLng, map);
console.log(event.latLng.lat() +' _ ' + event.latLng.lng());
salvaPonto(event.latLng.lat(), event.latLng.lng());
event.latLng.empty();
}
});
});
}
function addMarker(location, map) {
var marker = new google.maps.Marker({
position: location,
label: "D",
map: map
});
}
google.maps.event.addDomListener(window, 'load', initialize);
in my function, every click on the maps a Marker is added. From what I understand of yours, loads markers already "ready" I am correct?
– Lucas Torres