我有以下传单代码:
<script>
var lat = '<%=_city.Gps.Latitude.ToString(CultureInfo.InvariantCulture) %>';
var lon = '<%=_city.Gps.Longitude.ToString(CultureInfo.InvariantCulture) %>';
var map = L.map('map').setView([lat, lon], 8);
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>'
}).addTo(map);
L.circle([lat, lon], 15000, {
color: 'orange',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map).bindPopup("XXXX.");
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}
</script>
我想做一个 AJAX 调用,以 JSON 格式为我提供数据。如何将 JQuery 合并到此传单脚本中?
这就是我的 AJAX 调用的样子:
$("#mymap").load(function () {
$.getJSON("Ajax/MyService.svc/GetCityCoordinates", function (response) {
var d = JSON.parse(response.d);
// Use leaflet code to mark the cities....
return false;
});
我需要帮助来混合这两个脚本块。有人可以帮助我如何混合这些 scipts 吗?