Javascript 在传单地图中使用动态标记
我正在开发一个动态映射应用程序,它以JSON的形式接收一系列数据,然后将这些数据转换为一个地图点,并在传单中弹出一个窗口 JSON数据如下所示:Javascript 在传单地图中使用动态标记,javascript,mapping,Javascript,Mapping,我正在开发一个动态映射应用程序,它以JSON的形式接收一系列数据,然后将这些数据转换为一个地图点,并在传单中弹出一个窗口 JSON数据如下所示: { "unit":"90", "latitude":36.120915, "longitude":-97.0633733, "velocity":0.022, "heading":102.9, "timestamp":"Wed, 23 Nov 2011 20:00:28 GMT" } 我有一个监听器设置来接收来自推送服务器的数据,该服务器调用
{
"unit":"90",
"latitude":36.120915,
"longitude":-97.0633733,
"velocity":0.022,
"heading":102.9,
"timestamp":"Wed, 23 Nov 2011 20:00:28 GMT"
}
我有一个监听器设置来接收来自推送服务器的数据,该服务器调用下面的函数来在地图上绘制设备的位置
function drawUnit(unit)
{
//removeUnitMarkers();
var popupContent = "<h3>" + unit.number + "</h3>";
popupContent = popupContent + "<p><strong>Direction: </strong>" + unit.heading + "<br />";
popupContent = popupContent + "<strong>Speed: </strong>" + unit.velocity + "<br />";
popupContent = popupContent + "<strong>Last Update:</strong> " + unit.timestamp + "<br /></p>";
var markerLocation = new L.LatLng(unit.latitude,unit.longitude);
var marker = new L.Marker(markerLocation);
var unitNumber = unit.number;
var unitTest = 'test';
console.log(unitData);
unitLayerGroup.addLayer(marker);
marker.bindPopup(popupContent);
//unitMarkerCache.push(marker);
//map.panTo(markerLocation);
}
像上面那样做var标记[unit.number]
不起作用;Firebug总是抛出一个错误:
missing ; before statement
第161行
这是第161行:var-marker[unit.number]=新的L.marker(markerLocation);
missing ; before statement