AJAX and JSONP in Leaflet
alows you to call json over ajax either localally or with jsonp, for local json the api is pretty much the same
var geojsonLayer = AJAX"geojson.json";
for jsonp add the option "dataType" and set it to "jsonp"
var geojsonLayer = LgeoJsonajax"http:webhost.fake/geojson.jsonp"dataType:"jsonp";
as you see you can also use lower case methods without creating new objects
for weirder jsonp you can set "callbackParam" for if you need to change the name of the callback parameter to something besides "callback", e.g. Mapquest Nominative Open uses "json_callback" instead of "callback".
gives off two events
you can also add a middleware function which is called after you download the data but before you add it to leaflet:
var geojsonLayer = LgeoJsonajax"route/to/esri.json"doStuff;return geojson;;
addUrl does not clear the currenlt layers but adds to the current one, e.g.:
var geojsonLayer = LgeoJsonajax"data.json";geojsonLayeraddUrl"data2.json";//we now have 2 layersgeojsonLayerrefresh;//redownload the most recent layergeojsonLayerrefresh"new1.json";//add a new layer replacing whatever is there
last but now least we can refilter layers without re adding them
var geojsonLayer = LgeoJsonajax"data.json";geojsonLayerrefilterreturn featurepropertieskey === values;;
behind the scenes are two new classes L.Util.ajax = function (url, cb) for same origin requests and L.Util.jsonp = function (url, cb, cbParam, callbackName) cross origin ones, meaning you don't actually have to use this with the built in layer type, you can do
some of the jsonp code inspired by/taken from this interesting looking plugin that I have failed to make heads nor tails of (the plugin, not the jsonp code)