【问题标题】:display and view geofencing in googlemaps using ionic2使用 ionic 2 在谷歌地图中显示和查看地理围栏
【发布时间】: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 我指的是圈子,提到栅栏

标签: google-maps angular ionic-framework ionic2 android-geofence


【解决方案1】:

如果您想使用 Google 地图 API 进行地理围栏,请通过Ionic2 Geofence using Google maps api

【讨论】:

    【解决方案2】:

    如果你需要实现上述插件,那么你必须做更多的事情并导入更多的插件。这样一个根插件是import * as Leaflet from "leaflet";

    在 Git repo 下面,他们已经为 Ionic 2 完美地实现了它。所以继续玩吧。它对我来说很好。如果您有任何问题,请在下面发表评论。

    Git repo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-26
      • 2013-02-16
      • 2013-05-06
      • 1970-01-01
      • 1970-01-01
      • 2018-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多