Leaflet(Esri)初识

加载本地地图
<html>
<head>
<metacharset=utf-8/>
<title>IdentifyingFeatures</title>
<metaname='viewport'content='initial-scale=1,maximum-scale=1,user-scalable=no'/>

<!--从CDN上引入leaflet的文件-->
<linkrel="stylesheet"href="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.css"/>
<scriptsrc="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.js"></script>

<!--从CDN上引入Esri的包-->
<scriptsrc="//cdn-geoweb.s3.amazonaws.com/esri-leaflet/1.0.0-rc.6/esri-leaflet.js"></script>

<style>
body{margin:0;padding:0;}
#map{position:absolute;top:0;bottom:0;right:0;left:0;}
</style>
</head>
<body>

<style>
#selectedFeatures{
position:absolute;
top:10px;
right:10px;
z-index:10;
background:white;
padding:1em;
}
</style>

<divid="map"></div>
<script>
varmap=L.map('map').setView([34.03,103.8],13);

L.esri.basemapLayer('Gray').addTo(map);

varGSAU=L.esri.dynamicMapLayer('http://localhost:6080/arcgis/rest/services/GSAU/20141107NetworkAnalysise/MapServer',{
opacity:0.5,
useCors:false
}).addTo(map);

varidentifiedFeature;
map.on('click',function(e){
if(identifiedFeature){
map.removeLayer(identifiedFeature);
}
GSAU.identify().on(map).at(e.latlng).run(function(error,featureCollection){
identifiedFeature=newL.GeoJSON(featureCollection.features[0],{
style:function(){
return{
color:'#5C7DB8',
weight:2
};
}
}).addTo(map);
});
});
</script>
</body>
</html>    


这么多的链式函数???不要大惊小怪,通过查看leaflet(Esri)的API可以看到,大多函数返回的都是this.再打开控制台,键入this,奇迹出现了,就是window,是不是明白什么了????
原文地址:https://www.cnblogs.com/shangguanjinwen/p/4448816.html