問題描述
我是傳單和 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="leaflet.ajax.min"></script>
這篇關于將外部geojson添加到傳單層的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!