小编Jar*_*red的帖子

如何使用Google Maps SDK(Swift/iOS)在地图标记周围绘制半径?

用户可以通过两种方式将标记放置在应用程序中的地图上 - 通过地图上方的UISearchBar(尚未完成),并长按地图上他们希望标记出现的位置.我正在为标记使用全局变量,因为用户仅限于在地图上设置一个标记.每当创建标记时,我想在标记周围绘制一个半径(圆圈).到目前为止,这是我的代码:

var mapMarker = GMSMarker()
...

 //This function dectects a long press on the map and places a marker at the coordinates of the long press.
func mapView(mapView: GMSMapView!, didLongPressAtCoordinate coordinate: CLLocationCoordinate2D) {

        //Set variable to latitude of didLongPressAtCoordinate
        var latitude = coordinate.latitude

        //Set variable to longitude of didLongPressAtCoordinate
        var longitude = coordinate.longitude

        //Feed position to mapMarker
        mapMarker.position = CLLocationCoordinate2DMake(latitude, longitude)

        //Define attributes of the mapMarker.
        mapMarker.icon = UIImage(named: "mapmarkericon")

        //Set icon anchor point
        mapMarker.groundAnchor = CGPoint(x: 0.5, …
Run Code Online (Sandbox Code Playgroud)

ios google-maps-sdk-ios swift

7
推荐指数
2
解决办法
7353
查看次数

标签 统计

google-maps-sdk-ios ×1

ios ×1

swift ×1