【发布时间】:2017-08-31 23:42:45
【问题描述】:
我正在开发一个 ionic 2 应用程序,我正在使用 ionic 原生地理围栏对地理围栏功能进行编码,我能够设置地理围栏半径数据并获取当前位置,但无法在谷歌地图上直观地查看它,包括屏幕截图下面的期望输出
HTML
<ion-item>
<ion-range [(ngModel)]="formData.radius" ngControl="radius" name="radius" #radius="ngModel" min="40" max="200" color="primary" pin="true" snaps="true" step="10">
</ion-range>
</ion-item>
TypeScript
import { Geolocation, Geofence } from 'ionic-native';
export class PlaceAddPage {
radius:number = 100;
constructor(private platform: Platform) {
this.platform.ready().then(() => {
// initialize the plugin
Geofence.initialize().then(
// resolved promise does not return a value
() => console.log('Geofence Plugin Ready'),
(err) => console.log(err)
)
})
}
initMap() {
Geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let latLng1 = new google.maps.LatLng(13.0608842, 80.2221805);
let GooleMap = new google.maps.Map(document.getElementById('mapfence'), {
center: latLng,
zoom: 15
});
let marker = new google.maps.Marker({
position: latLng,
map: GooleMap,
title: 'My Location',
});
});
}
}
期望的输出
【问题讨论】:
-
你现在得到的输出是什么? console.log 有错误吗?
-
@MurshidAhmed 我只能准备好地理围栏,但无法在地图中显示围栏
-
你说的栅栏是指圆圈还是别的什么
-
@Stallion 我指的是圈子,提到栅栏
-
@RohitKumarVinay 请通过此链接github.com/tsubik/ionic2-geofence/tree/master/src/pages/…
标签: google-maps angular ionic-framework ionic2 android-geofence