0

I am using socket.io to get new lat/long.

I have this html snippet to load the markers on a Google Maps V3

var socket = io.connect();

            socket.on('date', function(data){
                      $('#date').text(data.date);

                      var locations=[[33.9821000000001,-117.33547],[33.98247,-117.33537],[33.9830000000001,-117.33533]];
                      var currLatLong = new google.maps.LatLng(33.9821000000001,-117.33547);
                      var mapOptions = {
                      zoom: 14,
                      center: currLatLong
                      }
                      var map = new google.maps.Map(document.getElementById('map'), mapOptions);


                      marker = new google.maps.Marker({
                         position: new google.maps.LatLng(currLatLong),
                         map: map,
                         title:"a",
                         });
                      console.log(marker);

                      });

But, the markers does not load and the Console gives no errors or warnings.

Umesh Moghariya
  • 3,063
  • 6
  • 21
  • 23

1 Answers1

0

currLatLong is already defined as LatLng object. Therefore, if the map is loading perfectly but the marker isn't, this should solve the problem:

marker = new google.maps.Marker({
    position: currLatLong,
    map: map,
    title:"a" // also possible typo problem comma
});
alpakyol
  • 2,402
  • 2
  • 29
  • 35