Add external geojson to leaflet layer

ajax, geojson, leaflet

Solution

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>

Problem

I am new to leaflet and JavaScript. I was thinking I could use geocommons and GeoJSON to host data for a mapping project. 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&amp;lon=-1.551&amp;radius=3&amp;callback=?", {onEachFeature:popUp}); function popUp(feature, layer) { layer.bindPopup(feature.properties.name); } geojsonLayer.addTo(myMap); ```

Original source