0

I cannot seem to be able to add markers to the map. Search works fine and the map loads alright. Here is my code, could you please help me figure out what is wrong. Thanks!

function addMarker(place)
{
    myLatLng = new google.maps.LatLng(parseFloat(place.latitude), parseFloat(place.longitude));
    var marker = new MarkerWithLabel({
        icon: "http://maps.google.com/mapfiles/kml/pal2/icon31.png",    
        position: myLatlng,
        map: map,
        labelClass: "label",
        labelContent: place.place_name + ", " + place.admin_name1 + ", " + place.postal_code, 
        labelAnchor: new google.maps.Point(20,0)   
    });
    google.maps.event.addListener(marker, "click", function() 
        { 
        showInfo(marker, place.postal_code  ); });

    markers.push(marker);
}
1

If you went to Developer Tools > Console, you would probably see something like

ReferenceError: myLatlng is not defined

on some of the lines there.

The issue is that you assign myLatlng (with lowercase l) to the position property, but you declared myLatLng (with uppercase L).

Also, you should add var to the declaration of myLatLng.

You must log in to answer this question.

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