1. 程式人生 > >天地圖api 區劃聚合+海量點展示 區劃到鄉鎮

天地圖api 區劃聚合+海量點展示 區劃到鄉鎮

// 自定義圖片 var imageLayer = new AMap.ImageLayer({ // url: 'http://1.img.dianjiangla.com/jdAssets/jdCity.png', url: 'http://1.img.dianjiangla.com/jdAssets/jdQh.png', opacity:0.8, bounds: new AMap.Bounds( [118.8940912546568,29.20439576265778],[120.32081607375262,30.155545642054992
] ), zooms: [15.1, 20] }); var imageLayer1 = new AMap.ImageLayer({ // url: 'http://1.img.dianjiangla.com/jdAssets/jdQh.png', url: 'http://chuantu.biz/t6/173/1512980653x-1404793565.png', opacity:0.8, bounds: new AMap.Bounds( [118.8940912546568,29.20439576265778
],[120.32081607375262,30.155545642054992] ), zooms: [0, 12] }); var imageLayer2 = new AMap.ImageLayer({ // url: 'http://1.img.dianjiangla.com/jdAssets/8bei.png', url: 'http://www.bbvdd.com/d/201712111707229eg.png', opacity:0.8, bounds: new AMap.Bounds( [118.8940912546568
,29.20439576265778],[120.32081607375262,30.155545642054992] ), zooms: [12.1, 13] }); var imageLayer3 = new AMap.ImageLayer({ // url: 'http://1.img.dianjiangla.com/jdAssets/8bei.png', url: 'http://www.bbvdd.com/d/20171211171824rag.png', opacity:0.8, bounds: new AMap.Bounds( [118.8940912546568,29.20439576265778],[120.32081607375262,30.155545642054992] ), zooms: [13.1, 15] }); //建立地圖 var map = new AMap.Map('container', { resizeEnable: true, expandZoomRange:true, zooms:[4,20], zoom: 11, center: [119.286105,29.470681], layers: [ new AMap.TileLayer(), imageLayer, imageLayer1, imageLayer2, imageLayer3 // googleLayer ] }); var markers = [ "119.280698,29.474716","119.280597,29.471716","119.286696,29.474716","119.281695,29.478716", "119.286105,29.470681","119.226103,29.420683","119.296102,29.410682","119.226103,29.420683", "119.047696,29.320256","119.041697,29.330257","119.048698,29.330258","119.042698,29.330258", "119.307696,29.320256","119.221697,29.490257","119.048698,29.310258","119.242698,29.370258", ]; var infoWindow = new AMap.InfoWindow({autoMove:true,showShadow:true,offset:(0,0)}); for(var i = 0; i < markers.length; i += 1){ marker = new AMap.Marker({ position: markers[i].split(','), map: map, icon: new AMap.Icon({ size: new AMap.Size(30, 30), //圖示大小 imageSize: new AMap.Size(30, 30), image: "http://p1.so.qhimgs1.com/t01989df0653e0a5ac1.png", // imageOffset: new AMap.Pixel(-8, -30) }) }); marker.content='<h2>我是標題</h2>我是第'+i+'個資訊窗體的內容'; //給Marker繫結單擊事件 marker.on('mousemove', markerClick); marker.on('mouseout', markerCloseClick); // marker 的顯示和隱藏 map.on("zoomchange",function(){ if(map.getZoom()<10){ console.log(marker.th.icon) marker.hide( ) map.clearMap( ) } }); } function markerClick(e){ infoWindow.setContent(e.target.content); infoWindow.open(map, e.target.getPosition()); } function markerCloseClick(e){ infoWindow.close(); } //滑鼠點選選點 map.on('mousemove', function(e) { //經度 //緯度 var x = e.lnglat.getLng(); var y= e.lnglat.getLat(); if(29.205656<y&&y<29.774429&&118.896922<x&&x<119.765112){ $.ajax({ url:'http://172.30.34.63:6080/arcgis/rest/services/JDLand_XZM/MapServer/identify', data:'f=json&tolerance=5&returnGeometry=true&imageDisplay=1398%2C210%2C96&geometry=%7B"x"%3A'+x+'%2C"y"%3A'+y+'%7D&geometryType=esriGeometryPoint&sr=4326&mapExtent=118.94165999313367%2C29.6123519861085%2C119.90159041305554%2C29.756547542749125&layers=top', success:function( data ){ var a = JSON.parse(data) console.log( a ); var b = a.results[0].geometry.rings[0]; var polygonArr1 = new Array();//多邊形覆蓋物節點座標陣列 polygonArr1.push(b) var polygon1 = new AMap.Polygon({ path: polygonArr1,//設定多邊形邊界路徑 strokeColor: "#FF33FF", //線顏色 strokeOpacity: 0, //線透明度 strokeWeight: 0, //線寬 fillColor: "#f66", //填充色 fillOpacity: 0,//填充透明度 bubble:true, geodesic:true, zIndex:10, }); // // 監聽滑鼠移入、移除事件 polygon1.on("mouseover",function (e) { // polygon1.show( ) polygon1.setOptions({fillOpacity : 0.8,strokeOpacity:0.5,strokeWeight:3,}) }).on("mouseout",function () { polygon1.setOptions({fillOpacity : 0,strokeOpacity:0,strokeWeight:0,}) // polygon1.hide( ) }); polygon1.setMap(map); }, error:function(error){ console.log(error); return; } }); } }); //載入相關元件 AMapUI.load(['ui/geo/DistrictCluster', 'ui/misc/PointSimplifier', 'lib/$'], function(DistrictCluster, PointSimplifier, $) { window.DistrictCluster = DistrictCluster; //啟動頁面 });