0

When I run flask and open the map, I can't view the markers on the map. Is there something wrong with my addMarker function?

Thank you.

// Add marker for place to map
function addMarker(place)
{
//instantiate marker
//dont forget postal code
    var coords = new google.maps.LatLng(place.latitude, place.longitude);
    var marker = new google.maps.Marker({
        position: coords,
        map: map,
        title: place.place_name + ", " + place.admin_name,
        icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'
    });
    //change center of map to coords
    map.panTo(coords);
    //set marker
    marker.setMap(map);

    //get articles for place
    $.getJSON("/articles", {geo: place.postal_code}).done(function(data){
        if(!$.isEmptyObject(data)){
            var list = '';
            for(var i =0; i<data.length; i++){
                list += '<li>' + '<a href= "' + data[i].link + '">' + data[i].title + '</a>' + '</li>' + '<br>';
            }
            var contentString = '<ul>' + list + '</ul>';
        }else{
            contentString = '';
        }
    });
    //listen for clicks on marker - display info window
    google.maps.event.addListener(marker, "click", function(){
        showInfo(marker, contentString);
    });
    //append marker to markers = [];  --> This is to REMEMBER marker
    markers.push(marker);
}
2
  • Any feedback in the browser console? I cannot use this icon parameter in marker because of firefox "do not track". Aug 7 '18 at 13:15
  • Alright, I figured out from the browser console that there's something wrong with my removeMarkers() function and later rectified it. The map is now displaying the markers properly along with the info windows. Thanks for your help.
    – Prav Elan
    Aug 8 '18 at 12:57
0

According to the original poster:

I figured out from the browser console that there was something wrong with my removeMarkers() function, and later rectified it. The map is now displaying the markers properly along the info windows.

My advice for those of you suffering similar issues are to investigate all your functions which could cause this, and to use the developer console! It can give some excellent hints.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .