0
Hello, I’m working with google maps, everything was going ok, but when I started using the markers, the same are getting duplicated in some locations, this happens when I’m walking and stand somewhere, when I move again and the GPS updates my position, in the place where I stood there is a marked, as if it were a cache, but the way I’m handling the bookmarks wasn’t supposed to happen, I’ve disabled the page cache and nothing, if it has ever happened to anyone or if anyone has any tips I will be very grateful, thank you for the attention, I’ll be putting the code I used to disable the browser cache and how I’m updating the bookmarks on the map.
Meta tags to disable cache
Removes all bookmarks to update them, I did it to see if it would stop duplicating
$.each(markers, function(index, marker) {
marker.setMap(null);
});
======================================================================
This variable is created at the beginning of the script
var markers = [];
here is the content of a function that keeps giving get with the device information ()
if (markers[device.id] == undefined) {
markers[device.id] = new google.maps.Marker({
position: { lat: device.lat, lng: device.lng },
map: map,
title: device.name
});
} else {
markers[device.id].setPosition( { lat: device.lat, lng: device.lng } );
}
I have a similar script. The difference is in if, I’m using 'if (markers.hasOwnProperty(device.id)) {' . You have checked if you are falling into Else correctly?
– André Vicente
Yes friend, the markers are being updated perfectly, what seems to me is something related to cache, but I have already disabled the cache with meta tags and disabled the cache of views of the frame work that I am using, Laravel 5.2, and this only happens when the GPS is stationary (sometimes), when he updates the position is a marker where he was, as if it were from some cache!
– Silas Vasconcelos