| | |
| | | var map = new AMap.Map('container',{ |
| | | resizeEnable: true, |
| | | zoom:10 |
| | | zoom:15 |
| | | }); |
| | | setCenterCoordinate(); |
| | | function setCenterCoordinate() { |
| | | var locationsStr = $("#locationList1").val(); |
| | | if ("" != locationsStr && null != locationsStr) { |
| | | var locations = JSON.parse(locationsStr); |
| | | var gid = locations[0].coordinate; |
| | | var path = convertData(gid); |
| | | var center = path[0]; |
| | | map.setCenter(center) |
| | | } |
| | | } |
| | | function setElectricFence() { |
| | | var locationsStr = $("#locationList1").val(); |
| | | if ("" != locationsStr && null != locationsStr) { |
| | | var locations = JSON.parse(locationsStr); |
| | | for (let i = 0; i < locations.length; i++) { |
| | | console.log(locations[i]) |
| | | var gid = locations[i].coordinate |
| | | if (gid == null || gid == "") { |
| | | continue; |
| | | } |
| | | var path = convertData(gid) |
| | | var polygon = new AMap.Polygon({ |
| | | path: path, |
| | | strokeWeight: 1, |
| | | fillOpacity: 0.4, |
| | | fillColor: '#00b0ff', |
| | | strokeColor: '#80d8ff' |
| | | }); |
| | | map.add(polygon); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function convertData(data) { |
| | | var coordinates = data.split(';'); |
| | | var path = []; |
| | | for (var i = 0; i < coordinates.length; i++) { |
| | | var coordinate = coordinates[i].split(','); |
| | | var lng = parseFloat(coordinate[0]); |
| | | var lat = parseFloat(coordinate[1]); |
| | | path.push([lng, lat]); |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | var value = ""; |
| | | map.getCity( |
| | |
| | | case 'circle':{//圆形 |
| | | var center = e.obj.getCenter(); |
| | | var radius = e.obj.getRadius(); |
| | | if(radius > 5000){ |
| | | Feng.error("创建电子围栏失败,圆半径不能大于5000米"); |
| | | return; |
| | | } |
| | | coordinate += center.lng + ',' + center.lat + ';' + radius + "_"; |
| | | objs.circle.push(e.obj); |
| | | break; |
| | |
| | | |
| | | circleEditor.on('adjust', function(e) { |
| | | var radius = e.target.getRadius(); |
| | | if(radius > 5000){ |
| | | Feng.error("创建电子围栏失败,圆半径不能大于5000米"); |
| | | return; |
| | | } |
| | | }) |
| | | |
| | | circleEditor.on('end', function(e) { |
| | |
| | | editor.close(); |
| | | } |
| | | } |
| | | $(function () { |
| | | setElectricFence() |
| | | }) |