码迷,mamicode.com
首页 > 其他好文 > 详细

Leaflet(Esri)初识

时间:2015-04-22 23:39:59      阅读:497      评论:0      收藏:0      [点我收藏+]

标签:

加载本地地图
<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,是不是明白什么了????

Leaflet(Esri)初识

标签:

原文地址:http://www.cnblogs.com/shangguanjinwen/p/4448816.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!