【问题标题】:Google maps creation of geofencing for iOS谷歌地图为 iOS 创建地理围栏
【发布时间】:2023-03-14 09:10:01
【问题描述】:

谷歌地图是否提供在 iOS 中创建地理围栏的功能?

在 Android 上与此类似: http://developer.android.com/training/location/geofencing.html

谢谢。

【问题讨论】:

  • 提供你所做的一些代码。
  • 我想在 iOS 中使用谷歌地图创建地理围栏,但我找不到相关的 api

标签: google-maps google-maps-sdk-ios geofencing


【解决方案1】:

以防万一其他人在这里结束:

https://www.raywenderlich.com/136165/core-location-geofencing-tutorial

当您的设备进入或离开您设置的地理区域时,地理围栏会通知您的应用。它可以让您制作酷炫的东西,每当您离开家时就会触发通知,或者只要您喜欢的商店在附近,就可以用最新和最优惠的价格向用户致意。在本地理围栏教程中,您将学习如何在 iOS 中通过 Swift 使用区域监控——在 Core Location 中使用区域监控 API。[...]

【讨论】:

  • @return0 谢谢,我没有澄清。谷歌地图是否提供在 iOS 中创建地理围栏的功能? => 没有。所以你必须用核心位置来做
  • 啊,好吧,这是有道理的。那么,您应该将其包含在原始答案中。
【解决方案2】:

在 swift 5 中,您可以使用 Google 地图对象创建地理围栏。在视图中加载或代码中您要初始化路径的任何地方只需实例化 GMSMutablePath 对象

 var path : GMSMutablePath!
 //In viewdidload
 path = GMSMutablePath()
 let lat  = Double(i.latitude ?? "0") ?? 0.0
 let lng =  Double(i.longitude ?? "0") ?? 0.0
 print(lat,lng)
 path.add(CLLocationCoordinate2D(latitude: lat, longitude: lng))
 let polyline = GMSPolyline(path: path)
 polyline.strokeColor = AppColor.authFontColor
 polyline.strokeWidth = 3.0
 polyline.map = googleMapView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 2016-10-18
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多