user3085296 user3085296 - 7 months ago 71
Ajax Question

Add external geojson to leaflet layer

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("", {onEachFeature:popUp});

function popUp(feature, layer) {



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" type=text/javascript""></script>