A
A
Alice7772018-07-09 15:26:21
JavaScript
Alice777, 2018-07-09 15:26:21

Why, for no reason, after a year of work, the contents of the markers on the Google map suddenly ceased to be displayed?

Google map stopped showing the content of the markers. There have been problems before. I fixed it by adding V3 (version) before the key and everything worked. You click on the label, a window with information appears and everything is fine.

Then suddenly, after a while, the info window stopped opening when clicking on the label, for no reason at all. How to solve this issue? What can I have with the api key?

here is the code:

var markersData = [

    {
        lat: 25.7742700,
        lng: -80.1936600,
        img: "/wp-content/themes/mopga/images/USA.jpg"
    },
    {
        lat: 58.0275892,
        lng: 11.5571489,
        img: "/images/Sweden.jpg"
    },
    {
        lat: 55.6759400,
        lng: 12.56553007,
        img: "/images/Danemark.jpg"
    },
    {
        lat: 41.811248,
        lng: 9.184666,
        img: "/images/Corse_France.jpg"
    },
    {
        lat: 9.9173500,
        lng: 78.1196200,
        img: "/images/India.jpg"
    },
    {
        lat: 45.5088400,
        lng: -73.5878100,
        img: "/images/Canada.jpg"
    }
];

var map, infoWindow;

function initMap() {

    var mapOptions = {
        center: new google.maps.LatLng(30.6977178, 14.727604),
        zoom: 3,
        navigationControl: false,
        streetViewControl: false
       
    };

    map = new google.maps.Map(document.getElementById("map"), mapOptions);

    infoWindow = new google.maps.InfoWindow();

    google.maps.event.addListener(map, "click", function() {

        infoWindow.close();
    });


    for (var i = 0; i < markersData.length; i++){

        var latLng = new google.maps.LatLng(markersData[i].lat, markersData[i].lng);
        var img = markersData[i].img;

        addMarker(latLng, img);

    }

}


jQuery(document).on('ready', function(){
    // google.maps.event.addDomListener(window, "load", initMap);
    // already initialized via script url of google maps script
});

function addMarker(latLng, img) {
    var marker = new google.maps.Marker({
        position: latLng,
        map: map,
        title: name,
    });
    marker.setZIndex(999);

    google.maps.event.addListener(marker, "click", function() {


        var contentString = '<div class="infowindow">' +
            '<div style="background-image: url('+ img +');" class="map-image">' + '</div>' +

            '</div>';



        infoWindow.setContent(contentString);


        infoWindow.open(map, marker);

    });
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GilbertAmethyst, 2018-07-09
@GilbertAmethyst

There is a possibility that these problems are related to Roskomnadzor and the fact that they banned some google / amazon servers and others. I have so several services fell off on the site, extremely spontaneously.

P
Pavel Novikov, 2018-07-09
@paulfcdd

try connecting another api key, if it doesn't help, then most likely it's because of rna, which blocks google's ip by millions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question