在Google Maps SDK for iOS中使用可拖动地图和固定标记来选择一个位置 [英] Select a position using draggable map and fixed marker in Google Maps SDK for iOS

查看:92
本文介绍了在Google Maps SDK for iOS中使用可拖动地图和固定标记来选择一个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手,现在正在尝试使用Google Maps SDK构建一个非常简单的导航应用程序。
所以我创建了一个地图并将其居中放置到用户的当前位置。



现在我需要实现以下功能:


  • 创建一个固定标记它始终保留在屏幕中央;
  • 让用户移动地图,因此固定标记将指向
    所需的位置。


  • $ b
    有人可以请一些想法的建议如何实现这一点,或与一些示例代码? 解决方案

对于固定标记,你可以在地图上添加一个小的UIButton。
在用户拖动地图并点击按钮后,您可以在地图中心找到位置。

  CLLocationCoordinate2D location = mapView.camera.target; 


I'm newbie to iOS development and now trying to build a very simple navigation app using Google Maps SDK. So I created a map and centered it to current position of user.

Now I need to implement the following functionality:

  • make a fixed marker that always remains in the center in a screen;
  • let the user move the map, so the fixed marker will be pointed to desired position.
  • to write coordinates of this position in some variable when user taps on marker.

Can someone please advice with some ideas how to achieve this, or with some sample code?

解决方案

For the fixed marker, you can add a small UIButton on top of your map. After the user pans the map and taps your button, you can get the location centered in map

CLLocationCoordinate2D location = mapView.camera.target;

这篇关于在Google Maps SDK for iOS中使用可拖动地图和固定标记来选择一个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆