Add external geojson to leaflet layer(将外部geojson添加到传单层)
问题描述
我是传单和 JavaScript 的新手.我在想我可以使用 geocommons 和 GeoJSON 来托管地图项目的数据.
I am new to leaflet and JavaScript. I was thinking I could use geocommons and GeoJSON to host data for a mapping project.
我发现 外部 GeoJSON 和 Leaflet:另一种方式).本教程使用传单插件读取外部 GeoJSON,但我无法获得它来获取要在我的地图上渲染的点.代码的地图部分渲染良好,但 GeoJSON 不会出现.
I found External GeoJSON and Leaflet: The Other Way(s). This tutorial on reading external GeoJSON using a leaflet plugin but I haven't been able to get it to get the points to render on my map. The map portion of the code renders fine but the GeoJSON won't appear.
var geojsonLayer = new L.GeoJSON.AJAX("http://geocommons.com/datasets/168923/features.json?lat=53.796&lon=-1.551&radius=3&callback=?", {onEachFeature:popUp});
function popUp(feature, layer) {
layer.bindPopup(feature.properties.name);
}
geojsonLayer.addTo(myMap);
推荐答案
保存leaflet.ajax plugin as leaflet.ajax.min.js
在与您的 html 页面相同的文件夹中,然后通过在其间添加此行来调用它<head>
标签
Save the leaflet.ajax plugin as leaflet.ajax.min.js
in the same folder as your html page, then call it by adding this line in between the <head>
tags
<script src="bGVhZmxldC5hamF4Lm1pbg=="></script>
这篇关于将外部geojson添加到传单层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将外部geojson添加到传单层
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 失败的 Canvas 360 jquery 插件 2022-01-01