Postgresql 使用传单中pgAdminIII的内容创建弹出窗口
我在创建弹出窗口时遇到问题,无法将postgres数据库中的内容放入传单中。我的数据库已连接,点显示为图层,但弹出窗口不显示内容。如何指定要在窗口中放置哪些属性?当您使用数据库中的geojson功能创建传单层时,如下所示:Postgresql 使用传单中pgAdminIII的内容创建弹出窗口,postgresql,leaflet,Postgresql,Leaflet,我在创建弹出窗口时遇到问题,无法将postgres数据库中的内容放入传单中。我的数据库已连接,点显示为图层,但弹出窗口不显示内容。如何指定要在窗口中放置哪些属性?当您使用数据库中的geojson功能创建传单层时,如下所示: L.geoJson(geojsonFeature, { onEachFeature: onEachFeature }).addTo(map); var geojsonFeature = { "type": "Feature", "properties
L.geoJson(geojsonFeature, {
onEachFeature: onEachFeature
}).addTo(map);
var geojsonFeature = {
"type": "Feature",
"properties": {
"YourPropertyName": "Coors Field",
"anotherProperty": "Baseball Stadium"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};
您可以使用onEachFeature选项调用自己的函数,该函数将定义每个功能的弹出内容:
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.YourPropertyName) {
layer.bindPopup(feature.properties.YourPropertyName);
}
}
在这种情况下:从数据库接收的geojson至少应包含如下指定属性:
L.geoJson(geojsonFeature, {
onEachFeature: onEachFeature
}).addTo(map);
var geojsonFeature = {
"type": "Feature",
"properties": {
"YourPropertyName": "Coors Field",
"anotherProperty": "Baseball Stadium"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};
希望这有帮助