用户可以通过两种方式将标记放置在应用程序中的地图上 - 通过地图上方的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)