提交 6ccebdcd 编写于 作者: Shine-zwj's avatar Shine-zwj

update:更新地图定位控件默认定位

上级 bc6922e9
...@@ -93,17 +93,17 @@ export default class AppMobMapPage extends Vue { ...@@ -93,17 +93,17 @@ export default class AppMobMapPage extends Vue {
* @type {*} * @type {*}
* @memberof AppMobMapPage * @memberof AppMobMapPage
*/ */
public center: any[] = [104.09427199999999, 30.660396]; public center: any[] = [104.067836, 30.606631];
/** /**
* 地图标点信息 * 地图标点信息(无定位默认标点)
* *
* @type {*} * @type {*}
* @memberof AppMobMapPage * @memberof AppMobMapPage
*/ */
public marker: any = { public marker: any = {
position: [104.09427199999999, 30.660396], position: [104.067836, 30.606631],
address: '成都', address: '四川省成都市武侯区桂溪街道天府大道北段成都南站',
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
visible: false visible: false
}; };
...@@ -163,16 +163,21 @@ export default class AppMobMapPage extends Vue { ...@@ -163,16 +163,21 @@ export default class AppMobMapPage extends Vue {
* @memberof AppMobMapPage * @memberof AppMobMapPage
*/ */
initCurAddress(o: any) { initCurAddress(o: any) {
if (!this.marker.visible && !this.address) { if (!this.marker.visible) {
o.getCurrentPosition((status: any, result: any) => { if (this.address) {
if (result && result.position) { this.handleSearch();
this.center = [result.position.lng, result.position.lat]; } else {
this.address = result.formattedAddress; o.getCurrentPosition((status: any, result: any) => {
Object.assign(this.marker, { position: this.center, address: this.address, visible: true }); if (result && result.status != 0) {
} this.center = [result.position.lng, result.position.lat];
}); this.address = result.formattedAddress;
} else if (this.address) { Object.assign(this.marker, { position: this.center, address: this.address, visible: true });
this.handleSearch(); } else {
this.address = this.marker.address;
console.warn('定位失败');
}
});
}
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册