|
@@ -20,7 +20,19 @@ export function useAMap(options) {
|
|
version: !!options.version ? options.version : '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
version: !!options.version ? options.version : '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
plugins: options.plugins
|
|
plugins: options.plugins
|
|
? options.plugins
|
|
? options.plugins
|
|
- : ['AMap.Scale', 'AMap.RangingTool', 'AMap.MouseTool', 'AMap.PolygonEditor', 'AMap.MarkerCluster', 'AMap.DistrictSearch', 'AMap.MoveAnimation', 'AMap.Driving', 'AMap.Geocoder', 'AMap.PlaceSearch', 'AMap.GeoJSON']
|
|
|
|
|
|
+ : [
|
|
|
|
+ 'AMap.Scale',
|
|
|
|
+ 'AMap.RangingTool',
|
|
|
|
+ 'AMap.MouseTool',
|
|
|
|
+ 'AMap.PolygonEditor',
|
|
|
|
+ 'AMap.MarkerCluster',
|
|
|
|
+ 'AMap.DistrictSearch',
|
|
|
|
+ 'AMap.MoveAnimation',
|
|
|
|
+ 'AMap.Driving',
|
|
|
|
+ 'AMap.Geocoder',
|
|
|
|
+ 'AMap.PlaceSearch',
|
|
|
|
+ 'AMap.GeoJSON'
|
|
|
|
+ ]
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
AMap = res;
|
|
AMap = res;
|
|
map = new AMap.Map(options.el ? options.el : 'aMap', {
|
|
map = new AMap.Map(options.el ? options.el : 'aMap', {
|
|
@@ -63,9 +75,24 @@ export function useAMap(options) {
|
|
if (type === 'vectorgraph') {
|
|
if (type === 'vectorgraph') {
|
|
map.removeLayer(nowLayer);
|
|
map.removeLayer(nowLayer);
|
|
} else if (type === 'satellite') {
|
|
} else if (type === 'satellite') {
|
|
- const satellite = new AMap.TileLayer.Satellite();
|
|
|
|
- map.addLayer(satellite);
|
|
|
|
- nowLayer = satellite;
|
|
|
|
|
|
+ const wms = new AMap.TileLayer.WMTS({
|
|
|
|
+ // url: 'http://t0.tianditu.gov.cn/img_c/wmts',
|
|
|
|
+ url: 'http://t4.tianditu.gov.cn/img_w/wmts',
|
|
|
|
+ blend: false,
|
|
|
|
+ tileSize: 256,
|
|
|
|
+ params: {
|
|
|
|
+ Layer: 'img',
|
|
|
|
+ Version: '1.0.0',
|
|
|
|
+ Format: 'tiles',
|
|
|
|
+ TileMatrixSet: 'w',
|
|
|
|
+ STYLE: 'default',
|
|
|
|
+ tk: 'a8df87f1695d224d2679aa805c1268d9' // 申请的天地图开发者key
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ wms.setMap(map);
|
|
|
|
+ // const satellite = new AMap.TileLayer.Satellite();
|
|
|
|
+ // map.addLayer(satellite);
|
|
|
|
+ // nowLayer = satellite;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
// 添加搜索的标记的
|
|
// 添加搜索的标记的
|
|
@@ -120,7 +147,7 @@ export function useAMap(options) {
|
|
context.marker.setContent(content);
|
|
context.marker.setContent(content);
|
|
context.marker.setOffset(offset);
|
|
context.marker.setOffset(offset);
|
|
context.marker.setExtData(context.data[0]);
|
|
context.marker.setExtData(context.data[0]);
|
|
- context.marker.on('click', function(e) {
|
|
|
|
|
|
+ context.marker.on('click', function (e) {
|
|
const extData = e.target.getExtData();
|
|
const extData = e.target.getExtData();
|
|
let index = 0;
|
|
let index = 0;
|
|
let index2 = 0;
|
|
let index2 = 0;
|
|
@@ -242,7 +269,7 @@ export function useAMap(options) {
|
|
new AMap.DistrictSearch({
|
|
new AMap.DistrictSearch({
|
|
extensions: 'all',
|
|
extensions: 'all',
|
|
subdistrict: 0
|
|
subdistrict: 0
|
|
- }).search(name, function(status, result) {
|
|
|
|
|
|
+ }).search(name, function (status, result) {
|
|
// 外多边形坐标数组和内多边形坐标数组
|
|
// 外多边形坐标数组和内多边形坐标数组
|
|
const outer = [
|
|
const outer = [
|
|
new AMap.LngLat(-360, 90, true),
|
|
new AMap.LngLat(-360, 90, true),
|
|
@@ -252,7 +279,7 @@ export function useAMap(options) {
|
|
];
|
|
];
|
|
options.forEach((option) => {
|
|
options.forEach((option) => {
|
|
const holes = result.districtList[0].boundaries;
|
|
const holes = result.districtList[0].boundaries;
|
|
- let pathArray = [outer];
|
|
|
|
|
|
+ const pathArray = [outer];
|
|
pathArray.push.apply(pathArray, holes);
|
|
pathArray.push.apply(pathArray, holes);
|
|
maskPolygon = new AMap.Polygon({
|
|
maskPolygon = new AMap.Polygon({
|
|
pathL: pathArray,
|
|
pathL: pathArray,
|
|
@@ -389,12 +416,12 @@ export function useAMap(options) {
|
|
strokeWeight: 6 //线宽
|
|
strokeWeight: 6 //线宽
|
|
});
|
|
});
|
|
|
|
|
|
- moveMarker.on('moving', function(e) {
|
|
|
|
|
|
+ moveMarker.on('moving', function (e) {
|
|
movePassedPolyline.setPath(e.passedPath);
|
|
movePassedPolyline.setPath(e.passedPath);
|
|
map.setCenter(e.target.getPosition(), true);
|
|
map.setCenter(e.target.getPosition(), true);
|
|
});
|
|
});
|
|
|
|
|
|
- moveMarker.on('moveend', function(e) {
|
|
|
|
|
|
+ moveMarker.on('moveend', function (e) {
|
|
index++;
|
|
index++;
|
|
if (index === lineArr.length - 1) {
|
|
if (index === lineArr.length - 1) {
|
|
timerId = setTimeout(() => {
|
|
timerId = setTimeout(() => {
|
|
@@ -413,7 +440,7 @@ export function useAMap(options) {
|
|
};
|
|
};
|
|
|
|
|
|
const drawData = (data) => {
|
|
const drawData = (data) => {
|
|
- let res = [];
|
|
|
|
|
|
+ const res = [];
|
|
data.forEach((item) => {
|
|
data.forEach((item) => {
|
|
let graphic;
|
|
let graphic;
|
|
if (['rectangle', 'polygon', 'anyLine'].includes(item.type)) {
|
|
if (['rectangle', 'polygon', 'anyLine'].includes(item.type)) {
|