| | |
| | | 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( |
| | | callback=function (result) { |
| | | value = result.city; |
| | | drawBounds(); |
| | | } |
| | | callback=function (result) { |
| | | value = result.city; |
| | | drawBounds(); |
| | | } |
| | | ); |
| | | |
| | | |
| | |
| | | mouseTool.on('draw',function(e){ |
| | | overlays.push(e.obj); |
| | | console.log(e.obj.getPath()); |
| | | |
| | | |
| | | switch (name) { |
| | | case 'polyline':{//折线图 |
| | | var polyline = e.obj.getPath(); |
| | |
| | | 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; |
| | |
| | | if(value == ''){ |
| | | value = '北京市'; |
| | | } |
| | | |
| | | |
| | | //加载行政区划插件 |
| | | if(!district){ |
| | | //实例化DistrictSearch |
| | |
| | | return; |
| | | } |
| | | coordinate = coordinate.substring(0, coordinate.length - 1); |
| | | |
| | | |
| | | } |
| | | |
| | | function editAll() { |
| | |
| | | polyEditor.on('addnode', function(event) { |
| | | // log.info('触发事件:addnode') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('adjust', function(event) { |
| | | // log.info('触发事件:adjust') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('removenode', function(event) { |
| | | // log.info('触发事件:removenode') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('end', function(e) { |
| | | var polyline = e.target.getPath(); |
| | | getCoordinate(polyline); |
| | |
| | | editors.push(polyEditor); |
| | | polyEditor.open(); |
| | | } |
| | | |
| | | |
| | | //多边形 |
| | | for(var i in objs.polygon){ |
| | | var polygon = objs.polygon[i]; |
| | | var polyEditor = new AMap.PolyEditor(map, polygon) |
| | | |
| | | |
| | | polyEditor.on('addnode', function(event) { |
| | | // log.info('触发事件:addnode') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('adjust', function(event) { |
| | | // log.info('触发事件:adjust') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('removenode', function(event) { |
| | | // log.info('触发事件:removenode') |
| | | }) |
| | | |
| | | |
| | | polyEditor.on('end', function(e) { |
| | | var polygon = e.target.getPath(); |
| | | getCoordinate(polygon); |
| | |
| | | editors.push(polyEditor); |
| | | polyEditor.open(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //矩形 |
| | | for(var i in objs.rectangle){ |
| | | var rectangle = objs.rectangle[i]; |
| | | var rectangleEditor = new AMap.RectangleEditor(map, rectangle) |
| | | |
| | | |
| | | rectangleEditor.on('adjust', function(event) { |
| | | // log.info('触发事件:adjust') |
| | | }) |
| | | |
| | | |
| | | rectangleEditor.on('end', function(e) { |
| | | var polygon = e.target.getPath(); |
| | | getCoordinate(polygon); |
| | |
| | | editors.push(rectangleEditor); |
| | | rectangleEditor.open(); |
| | | } |
| | | |
| | | |
| | | //圆形 |
| | | for(var i in objs.circle){ |
| | | var circle = objs.circle[i]; |
| | | var circleEditor = new AMap.CircleEditor(map, circle) |
| | | |
| | | |
| | | circleEditor.on('move', function(event) { |
| | | // log.info('触发事件:move') |
| | | }) |
| | | |
| | | |
| | | circleEditor.on('adjust', function(e) { |
| | | var radius = e.target.getRadius(); |
| | | if(radius > 5000){ |
| | | Feng.error("创建电子围栏失败,圆半径不能大于5000米"); |
| | | return; |
| | | } |
| | | }) |
| | | |
| | | |
| | | circleEditor.on('end', function(e) { |
| | | var center = e.target.getCenter(); |
| | | var radius = e.target.getRadius(); |
| | |
| | | var editor = editors[i]; |
| | | editor.close(); |
| | | } |
| | | } |
| | | } |
| | | $(function () { |
| | | setElectricFence() |
| | | }) |