我正在使用socket.io
获取新的lat / long。
我有这个html代码段来加载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);
});
但是,标记没有加载,控制台没有给出任何错误或警告。
答案 0 :(得分:0)
currLatLong
已定义为LatLng
个对象。因此,如果地图加载完美但标记不是,则应解决问题:
marker = new google.maps.Marker({
position: currLatLong,
map: map,
title:"a" // also possible typo problem comma
});