|
|
@@ -26,7 +26,7 @@ import Tabbar from '../../components/Tabbar.vue'
|
|
|
import AMapLoader from "@amap/amap-jsapi-loader";
|
|
|
import { institutional,institutions_search} from '../../api/index.js'
|
|
|
window._AMapSecurityConfig = {
|
|
|
- securityJsCode: '0f17176ade9bdeee2ed7b9990e6423bd',
|
|
|
+ securityJsCode: process.env.VUE_APP_AMAP_SECURITY,
|
|
|
};
|
|
|
const radius = 2500 //圆半径
|
|
|
var map
|
|
|
@@ -57,27 +57,40 @@ export default {
|
|
|
addMarkersList:[]
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.mapInit()
|
|
|
+ async mounted() {
|
|
|
+ let that = this;
|
|
|
+ //1. 调用爱山东获取经纬度
|
|
|
+ lightAppJssdk.map.getLocation ({
|
|
|
+ success:function(data){ //成功
|
|
|
+ that.latitude =String(data.latitude)
|
|
|
+ that.longitude =String(data.longitude)
|
|
|
+ that.mapInit()
|
|
|
+ },
|
|
|
+ fail:function(err){ //错误
|
|
|
+ that.mapInit()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 2. 开发使用
|
|
|
+ // that.mapInit()
|
|
|
+
|
|
|
},
|
|
|
created() {
|
|
|
window.jumpDetailTap=(id)=>{
|
|
|
-
|
|
|
- console.log('跳转到详情页:'+id);
|
|
|
this.$router.push({path:'/detail',query:{institutionsId:id}})
|
|
|
}
|
|
|
- this.getInstitutional()
|
|
|
- this.getInstitutions_search()
|
|
|
+ // this.getInstitutional()
|
|
|
+ // this.getInstitutions_search()
|
|
|
},
|
|
|
methods: {
|
|
|
async getInstitutional() {
|
|
|
var institutionalData = await institutional();
|
|
|
- institutionalData.data.splice(0, 0, this.allInfo);
|
|
|
+ // institutionalData.data.splice(0, 0, this.allInfo);
|
|
|
this.categorieList = institutionalData.data
|
|
|
+ this.clickTab(this.categorieList[0].id)
|
|
|
},
|
|
|
|
|
|
async getInstitutions_search() {
|
|
|
- console.log('tab点击2:')
|
|
|
this.removeMarkers()
|
|
|
var institutionSearch = await institutions_search({
|
|
|
"radius": radius,
|
|
|
@@ -85,13 +98,10 @@ export default {
|
|
|
"lat": this.latitude,
|
|
|
"lng": this.longitude
|
|
|
})
|
|
|
- console.log('tab点击3:'+institutionSearch.rows)
|
|
|
let markersTemp = []
|
|
|
institutionSearch.rows.forEach((e, index) => {
|
|
|
markersTemp.push(this.formatData(e, index))
|
|
|
});
|
|
|
- console.log("15分钟搜索接口");
|
|
|
- console.log(markersTemp);
|
|
|
this.institutionList = institutionSearch.rows
|
|
|
this.markers = markersTemp
|
|
|
this.addMarkers();
|
|
|
@@ -207,53 +217,10 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**地图初始化 */
|
|
|
- async initMap() {
|
|
|
- await AMapLoader.load({
|
|
|
- key: "017ac002b4b1a16ec87b2182b17bbed9", //process.env.VITE_APP_AMAP_KEY,
|
|
|
- version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
|
- plugins: ["AMap.PlaceSearch", "AMap.AutoComplete", "AMap.Geolocation"], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
|
|
|
- })
|
|
|
- .then((AMap) => {
|
|
|
- AMapOut.value = AMap;
|
|
|
- map.value = new AMap.Map("container_home", {
|
|
|
- //设置地图容器id
|
|
|
- center: [114.057999, 22.5436],
|
|
|
- zoom: 11, //初始化地图级别
|
|
|
- });
|
|
|
-
|
|
|
- var autoOptions = {
|
|
|
- // 城市,默认全国
|
|
|
- city: "深圳",
|
|
|
- // 使用联想输入的input的id
|
|
|
- input: "address",
|
|
|
- };
|
|
|
-
|
|
|
- var autocomplete = new AMap.AutoComplete(autoOptions);
|
|
|
- placeSearch.value = new AMap.PlaceSearch({
|
|
|
- city: "深圳",
|
|
|
- citylimit: true,
|
|
|
- pageSize: 1, // 单页显示结果条数
|
|
|
- pageIndex: 1, // 页码
|
|
|
- });
|
|
|
- nextTick(()=>{
|
|
|
- var autocomplete = new AMap.AutoComplete(autoOptions);
|
|
|
- autocomplete.on("select", function add (e) {
|
|
|
- address.value = e.poi.name;
|
|
|
- });
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- .catch((e) => {
|
|
|
- console.log(e);
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
async mapInit(){
|
|
|
let that = this;
|
|
|
AMapOut = await AMapLoader.load({
|
|
|
- "key": "017ac002b4b1a16ec87b2182b17bbed9", // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
+ "key":process.env.VUE_APP_AMAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
"version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
|
"plugins": ["AMap.PlaceSearch", "AMap.AutoComplete", "AMap.Geolocation","AMap.InfoWindow"] //插件列表
|
|
|
})
|
|
|
@@ -270,6 +237,10 @@ export default {
|
|
|
that.longitude = e.lnglat.lng
|
|
|
that.handleEvent()
|
|
|
})
|
|
|
+ map.on('complete',function completeSource() {
|
|
|
+ that.getInstitutional()
|
|
|
+ })
|
|
|
+
|
|
|
mapCircle = new AMapOut.Circle({
|
|
|
center: new AMapOut.LngLat(that.longitude,that.latitude), // 圆心位置
|
|
|
radius: radius, //半径
|
|
|
@@ -292,50 +263,54 @@ export default {
|
|
|
that.longitude = e.poi.location.lng
|
|
|
that.handleEvent(e)
|
|
|
});
|
|
|
-
|
|
|
- // var windowContent =
|
|
|
- // '<div class="custom-content-window">' +
|
|
|
- // '测试跳转跳转调准大幅度' +
|
|
|
- // '</div>';
|
|
|
-
|
|
|
+
|
|
|
infoWindow = new AMapOut.InfoWindow({
|
|
|
isCustom:true,
|
|
|
- // content: windowContent,
|
|
|
+ closeWhenClickMap:true,
|
|
|
anchor: 'top-center',
|
|
|
offset: [0,-135]
|
|
|
});
|
|
|
- var geolocation =new AMapOut.Geolocation({
|
|
|
- enableHighAccuracy: false,//是否使用高精度定位,默认:true
|
|
|
- timeout: 30000, //超过10秒后停止定位,默认:无穷大
|
|
|
- maximumAge: 0, //定位结果缓存0毫秒,默认:0
|
|
|
- convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
|
|
|
- showButton: true, //显示定位按钮,默认:true
|
|
|
- buttonPosition: 'RT', //定位按钮停靠位置,默认:'LB',左下角
|
|
|
- buttonOffset: new AMapOut.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
- showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
|
|
|
- showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
|
|
|
- panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
|
|
|
- zoomToAccuracy:true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
|
|
|
- });
|
|
|
- map.addControl(geolocation);
|
|
|
- geolocation.getCurrentPosition(function(status,result){
|
|
|
- if(status=='complete'){
|
|
|
- onComplete(result)
|
|
|
- }else{
|
|
|
- onError(result)
|
|
|
- }
|
|
|
- });
|
|
|
- function onComplete(result) {
|
|
|
- console.log(result)
|
|
|
+ // var geolocation =new AMapOut.Geolocation({
|
|
|
+ // enableHighAccuracy: false,//是否使用高精度定位,默认:true
|
|
|
+ // timeout: 30000, //超过10秒后停止定位,默认:无穷大
|
|
|
+ // maximumAge: 0, //定位结果缓存0毫秒,默认:0
|
|
|
+ // convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
|
|
|
+ // showButton: true, //显示定位按钮,默认:true
|
|
|
+ // buttonPosition: 'RT', //定位按钮停靠位置,默认:'LB',左下角
|
|
|
+ // buttonOffset: new AMapOut.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
+ // showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
|
|
|
+ // showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
|
|
|
+ // panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
|
|
|
+ // zoomToAccuracy:true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
+
|
|
|
+ // });
|
|
|
+ // map.addControl(geolocation);
|
|
|
+ // geolocation.getCurrentPosition(function(status,result){
|
|
|
+ // if(status=='complete'){
|
|
|
+ // onComplete(result)
|
|
|
+ // }else{
|
|
|
+ // onError(result)
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // function onComplete(result) {
|
|
|
+ // console.log(result)
|
|
|
|
|
|
- }
|
|
|
- function onError(err) {
|
|
|
- console.log(err)
|
|
|
- }
|
|
|
+ // }
|
|
|
+ // function onError(err) {
|
|
|
+ // console.log(err)
|
|
|
+ // }
|
|
|
|
|
|
},
|
|
|
|
|
|
+ // 从爱山东获取用户位置
|
|
|
+ getLocation() {
|
|
|
+ return new Promise((resolve,reject)=>{
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
// 搜索以及点击地图后的处理
|
|
|
handleEvent() {
|
|
|
map.setCenter([this.longitude,this.latitude],true,500)
|