Commit 928ff08c by 前端

修复bug

1 parent 2eff3920
...@@ -153,6 +153,7 @@ export default { ...@@ -153,6 +153,7 @@ export default {
trackList: [], // 历史poi点 trackList: [], // 历史poi点
poiInfoWindow: null, // 当前的弹框 poiInfoWindow: null, // 当前的弹框
markerList: {}, // poi点标记列表 markerList: {}, // poi点标记列表
showMapText: false, //是否地图展示道路、标题
}; };
}, },
mounted() { mounted() {
...@@ -164,20 +165,14 @@ export default { ...@@ -164,20 +165,14 @@ export default {
// 地图初始化 // 地图初始化
initMap() { initMap() {
let _this = this; let _this = this;
let plugins = [ let plugins = ["AMap.LngLat", "AMap.MassMarks", "AMap.Geocoder"];
"AMap.LngLat",
"AMap.AutoComplete",
"AMap.MassMarks",
"AMap.Geocoder",
];
_this.$mapInit({ plugins: plugins }).then((AMap) => { _this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false; _this.mapLoading = false;
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map", { _this.map = mapService.init("map", {
zoom: 15, zoom: 15,
viewMode: "3D",
showIndoorMap: false, showIndoorMap: false,
showLabel: true, showLabel: false,
}); });
_this.bindSearch(); _this.bindSearch();
_this.initMapEvent(); _this.initMapEvent();
...@@ -346,19 +341,20 @@ export default { ...@@ -346,19 +341,20 @@ export default {
// 绑定搜索 // 绑定搜索
bindSearch() { bindSearch() {
const _this = this; const _this = this;
AMap.plugin("AMap.AutoComplete", function () {
let autoComplete = new AMap.AutoComplete({
input: "poiMapSearch",
});
let autoComplete = new AMap.AutoComplete({ autoComplete.on("select", function (e) {
input: "poiMapSearch", console.log(e);
}); let _poi = e.poi || {};
let _params = {};
autoComplete.on("select", function (e) { _params.lng = _poi.location.lng;
console.log(e); _params.lat = _poi.location.lat;
let _poi = e.poi || {};
let _params = {};
_params.lng = _poi.location.lng;
_params.lat = _poi.location.lat;
_this.addPoiMarker(_params, "search"); _this.addPoiMarker(_params, "search");
});
}); });
}, },
...@@ -483,6 +479,7 @@ export default { ...@@ -483,6 +479,7 @@ export default {
_this.getInfo(); _this.getInfo();
} }
_this.trackList = res.data || []; _this.trackList = res.data || [];
_this.showRoadTitle();
} }
}); });
}, },
...@@ -501,7 +498,7 @@ export default { ...@@ -501,7 +498,7 @@ export default {
_obj.lng = arr[0]; _obj.lng = arr[0];
_obj.lat = arr[1]; _obj.lat = arr[1];
} }
console.log(_obj) console.log(_obj);
_this.addPoiMarker(_obj, "", true); _this.addPoiMarker(_obj, "", true);
}); });
}, },
...@@ -533,6 +530,13 @@ export default { ...@@ -533,6 +530,13 @@ export default {
}, 1000); }, 1000);
} }
}, },
// 展示隐藏地图标题
showRoadTitle() {
let _road = new AMap.TileLayer.RoadNet();
let _title = new AMap.TileLayer();
this.map.add([_title]);
},
}, },
}; };
</script> </script>
......
...@@ -779,7 +779,7 @@ export default { ...@@ -779,7 +779,7 @@ export default {
let _config = { version: "1.4.2" }; let _config = { version: "1.4.2" };
_config.AMapUI = { _config.AMapUI = {
version: "1.1", version: "1.1",
plugins: ["ui/misc/PathSimplifier"], plugins: ["/misc/PathSimplifier"],
}; };
_this.$mapInit(_config).then((AMap) => { _this.$mapInit(_config).then((AMap) => {
......
...@@ -237,11 +237,12 @@ export default { ...@@ -237,11 +237,12 @@ export default {
"AMap.MassMarks", "AMap.MassMarks",
"AMap.MarkerCluster", "AMap.MarkerCluster",
"AMap.Bounds", "AMap.Bounds",
"AMap.MouseTool"
]); ]);
_this.$mapInit({ plugins: plugins }).then((AMap) => { _this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false; _this.mapLoading = false;
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 11 }); _this.map = mapService.init("map", { zoom: 11, showLabel: false });
_this.mouseTool = new AMap.MouseTool(_this.map); _this.mouseTool = new AMap.MouseTool(_this.map);
var autoComplete = new AMap.AutoComplete({ var autoComplete = new AMap.AutoComplete({
input: "tipInput", input: "tipInput",
...@@ -259,6 +260,9 @@ export default { ...@@ -259,6 +260,9 @@ export default {
if (_query.type == "full" && _query.leftLngLat) { if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query); this.initPage(_query);
} }
// 给地图添加文字图层
_this.map.add([new AMap.TileLayer()]);
}); });
}, },
......
...@@ -3,13 +3,13 @@ import { CONSTANT } from "@/constant"; ...@@ -3,13 +3,13 @@ import { CONSTANT } from "@/constant";
export const mapInit = params => { export const mapInit = params => {
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
let options = params || {}; let options = params || {};
let plugins = options.plugins|| CONSTANT.MAP_PLUGINS; // let plugins = options.plugins|| CONSTANT.MAP_PLUGINS;
let version = options.version || '2.0'; // let version = options.version || '2.0';
if(window.AMap){ if(window.AMap){
resolve(window.AMap) resolve(window.AMap)
return false; return false;
} }
let mapConfig ={}; let mapConfig ={...options};
mapConfig.key = CONSTANT.MAP_KEY; // 申请好的Web端开发者Key,首次调用 load 时必填 mapConfig.key = CONSTANT.MAP_KEY; // 申请好的Web端开发者Key,首次调用 load 时必填
mapConfig.version = options.version || '2.0';; // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 mapConfig.version = options.version || '2.0';; // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
mapConfig.plugins = options.plugins|| CONSTANT.MAP_PLUGINS;// 需要使用的的插件列表,如比例尺'AMap.Scale'等 mapConfig.plugins = options.plugins|| CONSTANT.MAP_PLUGINS;// 需要使用的的插件列表,如比例尺'AMap.Scale'等
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!