Javascript GeoJSON功能未显示在地图上
我正在尝试将JSON格式化为GeoJSON,并用我创建的自定义图标显示在传单地图上。这可以使用L.Marker(注释掉)实现,但是在尝试将geojson功能添加到地图时,什么都不会出现Javascript GeoJSON功能未显示在地图上,javascript,json,leaflet,geojson,Javascript,Json,Leaflet,Geojson,我正在尝试将JSON格式化为GeoJSON,并用我创建的自定义图标显示在传单地图上。这可以使用L.Marker(注释掉)实现,但是在尝试将geojson功能添加到地图时,什么都不会出现 busses.forEach(function(bus) { /*L.marker([bus.vehicle.position.latitude, bus.vehicle.position.longitude], {rotationAngle: bus.vehicle.position.bearing,
busses.forEach(function(bus) {
/*L.marker([bus.vehicle.position.latitude, bus.vehicle.position.longitude], {rotationAngle: bus.vehicle.position.bearing, icon: busIcon}).addTo(layerGroup)
.bindPopup(FormatBusInformation(bus));*/
var geojsonFeature = {
"type": "Feature",
"properties": {
"id": bus.id,
"route": bus.vehicle.trip.routeId,
"popupContent": "Coming Soon"
},
"geometry": {
"type": "Point",
"coordinates": [bus.vehicle.position.latitude, bus.vehicle.position.longitude]
}
};
L.geoJSON(geojsonFeature, {
pointToLayer: (feature, latlng) => {
return L.marker(latlng, { icon: busIcon });
}
}).addTo(map);
});
GeoJSON坐标使用经度,纬度,而不是纬度,经度。看,例如@IvanSanchez,那是我的问题。谢谢你指出这一点。