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

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

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