, , - , AJAX. , , , .
, ( ) , , - L.geoJson. , onEachFeature, geoJSON.
, , , URL-, , , GeoJSON. - :
var markerdata = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-84.537291, 33.767675, 0]
},
"properties": {
"geometry": "Point",
"name": "Test Marker 1",
"url": "http://www.someurl.com/file_1.html"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-84.556685, 33.748580, 0]
},
"properties": {
"geometry": "Point",
"name": "Test Marker 2",
"url": "http://www.someotherurl.com/file_2.html"
}
}]
};
, :
function onEachMarker(feature, layer) {
layer.on('click', function (e) {
if (layer._popup != undefined) {
layer.unbindPopup();
}
var marker_url = feature.properties.url;
var pop = L.popup().setLatLng(this._latlng).setContent('Loading...').openOn(map);
$.ajax({
url: marker_url,
success: function (data) {
layer.closePopup();
layer.bindPopup(data);
});
layer.openPopup();
}
});
});
}
onEachFeature :
datalayer = L.geoJson(markerdata, {
onEachFeature: onEachMarker
}).addTo(map);
( ) . AJAX tumblr API URL- , geoJSON.
, , ( -) .get .ajax, console.log , . , .