F
F
Fayozzhon Berdiev2016-10-21 10:19:38
Google
Fayozzhon Berdiev, 2016-10-21 10:19:38

How to check if a token exists?

Good afternoon!
Please help to implement a check for the existence of a marker when dynamically adding it to the map.
I get an array with markers from the database on Ajax, I check
with such a code, then I add it if there was no marker at this location before

function markerExists(lat, lng) {
        var exists = false;
        var cache = markerCache; 
    var myLatLng = new google.maps.LatLng(lat, lng);
       angular.forEach(cache, function (record, i) {
            if(cache[i].getPosition().equals( myLatLng )){ 
                exists = true;
            }
        });
    
        return exists;
    }

The markers change their position when I zoomout or zoomin on the map.
Although their position should be static and not change.
For example, the marker was added earlier, when checking, I set console.log to output coordinates.
The same marker shows
zoom17, 41.346311 69.201538
zoom19, 41.351044, 69.178619
I would be grateful for the answers

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question