首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使Django-leaflet弹出窗口始终打开以显示django-geojson要素属性

使Django-leaflet弹出窗口始终打开以显示django-geojson要素属性
EN

Stack Overflow用户
提问于 2021-05-29 12:45:51
回答 1查看 22关注 0票数 0

我正在尝试使弹出窗口在django-leaflet上打开页面加载。我该怎么做呢?

代码语言:javascript
复制
var collection = {{ object_list|geojsonfeature:"popupContent"|safe }};
      console.log(collection);
    
    function onEachFeature(feature, layer) {
        if (feature.properties && feature.properties.popupContent) {
          layer.bindPopup(feature.properties.popupContent).openPopup();
        }
      }
EN

回答 1

Stack Overflow用户

发布于 2021-06-09 12:43:27

这是可行的:

代码语言:javascript
复制
 function onEachFeature(feature, layer) { 

    // does this feature have a property named popupContent?
    if (feature.properties && feature.properties.popupContent) {

        layer.addTo(map).bindPopup(feature.properties.popupContent,{autoClose:false}).openPopup();
};  

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67747817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档