Toggle navigation
定位与区域掩模
By
n***人
2018-10-25 07:29:17
脚本
16
21
作品使用的第三方脚本
//webapi.amap.com/maps?v=1.4.10&key=35a871e5905ecfd749bd998448b9cd03&plugin=AMap.DistrictSearch&plugin=AMap.Geolocation,/dep/echarts/latest/extension/bmap.min.js ,//api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
option = { title: { text: '位置获取中。。。。。', left: 'center', top: '0', textStyle: { color: 'rgba(18,89,147,1)', fontSize: 21 }, backgroundColor: 'rgba(255,255,255,0.8)' }, bmap: { roam: true, mapStyle: { style: "grayscale" } }, series: [{ coordinateSystem: 'bmap', type: 'effectScatter', symbol: 'arrow', itemStyle: { normal: { color: 'rgba(18,89,147,1)' } }, data: [] }] }; setTimeout(function() { var map = myChart.getModel().getComponent('bmap').getBMap(); map.addControl(new BMap.NavigationControl({})); // 添加平移缩放控件 map.addControl(new BMap.ScaleControl({})); // 添加比例尺控件 map.enableScrollWheelZoom(); //启用滚轮放大缩小 map.addControl(new BMap.MapTypeControl()); //添加地图类型控件 new AMap.Geolocation().getCurrentPosition(function(status, r) { var address = r.addressComponent; if (!address.city) { address.city = address.province.replace('市', '城区'); } addBoundary(address.province, address.city, address.district); function addBoundary(province, city, district) { new AMap.DistrictSearch({ level: 'province', subdistrict: 1, //返回下一级行政区 showbiz: false, //最后一级返回街道信息 extensions: 'base' }).search('中国', function(status, result) { if (status == 'complete') { result.districtList[0].districtList.forEach(function(item) { if (item.name != province) { draw(item.name); } else if (city) { new AMap.DistrictSearch({ level: 'city', subdistrict: 1, //返回下一级行政区 showbiz: false, //最后一级返回街道信息 extensions: 'base' }).search(item.name, function(status, result) { if (status == 'complete') { result.districtList[0].districtList.forEach(function(item) { if (item.name != city) { draw(item.name); } else if (district) { new AMap.DistrictSearch({ level: 'district', subdistrict: 1, //返回下一级行政区 showbiz: false, //最后一级返回街道信息 extensions: 'base' }).search(item.name, function(status, result) { if (status == 'complete') { result.districtList[0].districtList.forEach(function(item) { if (item.name != district) { draw(item.name); } }); } }); } }); } }); } }); } function draw(address) { new BMap.Boundary().get(address, function(rs) { //获取行政区域 rs.boundaries.forEach(function(item) { map.addOverlay(new BMap.Polygon(item, { strokeColor: 'white', fillColor: 'black', strokeWeight: 1, strokeOpacity: .01, fillOpacity: .521, // strokeStyle: 'dashed' })); }); }); } }); } map.centerAndZoom(address.city); setTimeout(function() { myChart.setOption({ title: { text: '当前位置:' + r.formattedAddress, }, tooltip: { show: true, backgroundColor: option.title.backgroundColor, formatter: function(params) { var infoWindow = new BMap.InfoWindow(); infoWindow.setWidth(0); infoWindow.setHeight(0); infoWindow.setTitle(r.formattedAddress); infoWindow.setContent('
省市区:' + address.province + '
' + '
地级市:' + address.city + '
' + '
区 县:' + address.district + '
' + '
街 道:' + (address.street ? address.street : '未知') + '
' + '
经 度:' + r.position.lng + '
' + '
纬 度:' + r.position.lat + '
'); map.openInfoWindow(infoWindow, new BMap.Point(r.position.lng, r.position.lat)); } }, series: [{ data: [{ name: address, value: [r.position.lng, r.position.lat] }] }] }); setTimeout(function() { //map.centerAndZoom(new BMap.Point(r.position.lng, r.position.lat), 16); myChart.dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: 0 }) }, 100); }, 100); }); }, 2000);