typescript - 传单地图不显示 GeoJSON 数据
问题描述
我正在尝试在嵌入 Power Bi 网络的传单地图上渲染一些点。提交给 Leaflet 的数据是 GeoJSON 格式。当我输入此数据时,一切正常并且该点正确显示:
var someFeatures = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-75, 34]
},
"properties": {
"name": "Location A"
}
}
]
}
然后我尝试插入我的数据,这只是一对纬度和经度。这是我正在运行的代码片段:
function onEachFeature(feature, layer) {
var popupContent = "<p>I started out as a GeoJSON " +
feature.geometry.type + ", but now I'm a Leaflet vector!</p>";
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
layer.bindPopup(popupContent);
}
var dat = Visual.converter(options.dataViews[0].table.rows); //just converts the data to lat lon format
var test = GeoJSON.parse(dat, {Point: ['lat', 'lon']})
L.geoJSON([test], {
style: function(feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature,
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, {
radius: 8,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
}).addTo(this.map);
我很确定数据以正确的格式转换,如开发人员控制台所示:
任何帮助都非常感谢,因为我不知道如何解决这个问题。
编辑:浏览器控制台输出是变量“test”的内容,其中填充了以下输出:GeoJSON.parse(dat, {Point: ['lat', 'lon']}) 其中“dat”是原始数据包含纬度和经度。
解决方案
推荐阅读
- javascript - 在 ReactJS 中,如何从父类更新子状态?
- python - 如何使用 tweepy 将 python panda 数据框保存在 csv 文件中
- regex - PowerShell 脚本 - 无法将值转换为正则表达式
- shell - 如何从输出中获取时间戳并与当前时间戳进行比较
- scala - Apache Tika 异常处理
- javascript - 循环遍历类并创建 noUislider
- amazon-web-services - 如何为我的 ALB 设置 NLB 以使用静态 IP
- sql - SQL Server 2018 如何在不同的列中分组信息
- firebase - 首先调用哪个方法?onKeyEntered(假设某些数据已返回)或 onGeoQueryReady
- python - Selenium:从子类元素中获取href