我将浏览Google Maps SDK for iOS入门页面,了解如何在给定边界上缩放和居中视图.Build a GMSCameraPosition中提供了此代码,其中提到"移动相机有时会使整个感兴趣区域以最大可能的缩放级别可见".
此措辞类似于通过GMSCameraUpdate的另一种可能方法,"返回一个GMSCameraUpdate,它可以转换摄像机,使指定的边界在屏幕上以最大可能的缩放级别居中."
下面的代码直接来自"入门"页面中的两个链接 - 稍微调整以提供有意义的屏幕截图; 适应性对实际结果没有影响.
- (void)loadView
{
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
CLLocationCoordinate2D vancouver = CLLocationCoordinate2DMake(49.26, -123.11);
CLLocationCoordinate2D calgary = CLLocationCoordinate2DMake(51.05, -114.05);
GMSMarker *vancouverMarker = [[GMSMarker alloc] init];
vancouverMarker.position = vancouver;
vancouverMarker.title = @"Vancouver";
vancouverMarker.map …Run Code Online (Sandbox Code Playgroud) 我有这个代码打开具有特定位置的Google Maps App并且它正在运行但我需要的是在该位置放置一个引脚,是否可能?
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(URL(string:
"comgooglemaps://?center=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&zoom=14&views=traffic")!)
} else {
print("Can't use comgooglemaps://");
}
Run Code Online (Sandbox Code Playgroud)
怎么做?
我在谷歌地图上设置了标记但是当我拖动它时,所有的地图都是拖动的.
点击并拖动时我想要拖动标记
单击并拖动标记外拖动地图.
这是我的代码
self.camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6 bearing:0 viewingAngle:0];
self.Map = [GMSMapView mapWithFrame:self.MapView.bounds camera:self.camera];
self.Map.myLocationEnabled = YES;
self.Map.delegate = self;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = self.camera.target;
marker.draggable = YES;
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = self.Map;
marker.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]];
marker.appearAnimation = kGMSMarkerAnimationPop;
[self.MapView addSubview:self.Map];
Run Code Online (Sandbox Code Playgroud)
这是拖拽事件
- (void) mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker
{
}
- (void) mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker
{
}
- (void) mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker
{
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的应用程序并调试所有上述事件不起作用.但事件点击标记工作很好. …
google-maps drag-and-drop objective-c ios google-maps-sdk-ios
德拉同事,
我很难用原生MKMapView实现可见区域.我需要具有与Google Map SDK可见区域完全相同的功能.

基本上它意味着在底部有一种填充到下面的代码:
let span = MKCoordinateSpan(latitudeDelta: 0.8, longitudeDelta: 0.8)
let reg = MKCoordinateRegion(center: someMyCoordinate, span: span)
mapView.setRegion(reg, animated: true)
Run Code Online (Sandbox Code Playgroud)
它必须是这样的:一旦我在UIView坐标中添加了一些填充,它应该移动地图中心并调整缩放以使坐标区域完全可见,同时考虑填充.
可能我的描述有点乱,但如果你看一下这个视频就会变得非常清楚.
先感谢您!
我正在使用Google Maps iOS SDK,并希望存储GMSPlace用户搜索的最近地点(对象).我遇到了检索这些地方的问题,因为它似乎不能GMSPlace直接实例化.
是否可以实例化GMSPlace对象?
谢谢!
我正在尝试在iOS应用上的Google Maps Marker上实现自定义信息窗口.(正如这里和这里所做的那样.)
我UIView为它创建了一个xib和一个类.它被称为CustomInfoWindow.xib和班级CustomInfoWindow.swift.
我的自定义信息窗口目前是空白的,即我还没有UIControl向我的xib 添加任何s.我还没有在我的类文件中添加任何代码.
该CustomInfoWindow.swift文件基本上看起来像:
import UIKit
class CustomInfoWindow: UIView {}
Run Code Online (Sandbox Code Playgroud)
在我的ViewController for my maps中,我的markerInfoWindow方法如下:
func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
let customInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as! CustomInfoWindow
return customInfoWindow
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码并单击我的一个标记时,空白CustomInfoWindow显示正常.
奇怪的是,当我CustomInfoWindow.xib在界面生成器中添加任何UI元素并再次运行我的应用程序时,然后突然当我点击标记时应用程序冻结.(例如,当我添加a UILabel或a UIImage时CustomInfoWindow.xib.)如果我删除了UI元素,那么空白笔尖在标记上显示正常.
如果我通过在一些View Controller上将它作为子视图添加来测试我的笔尖,那么它可以用我的UILabel和UIImage.但是,当我markerInfoWindow在应用程序冻结中使用相同的笔尖时.
问题是什么?
更新:此问题发生在适用于iOS的Google Maps SDK 1.13版本中,结果证明 …
目前,它在每个国家查询,但我希望它只在新加坡查询
我发现了一个stackoverflow解决方案如何使用Google自动完成位置api ios sdk获取特定国家/地区的结果?,但无法弄清楚我把代码放在哪里.
这是代码,我使用全屏解决方案进行自动完成.
import UIKit
import GoogleMaps
class OnlyLocationViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func clickMe(sender: UIButton) {
let autocompletecontroller = GMSAutocompleteViewController()
autocompletecontroller.delegate = self
self.presentViewController(autocompletecontroller, animated: true, completion: nil)
}
}
extension OnlyLocationViewController: GMSAutocompleteViewControllerDelegate{
func viewController(viewController: GMSAutocompleteViewController, didAutocompleteWithPlace place: GMSPlace) {
print("Place name: ", place.name)
print("Place address: …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装'Google-Maps-iOS-Utils',但它给了我上面的错误.这是Podfile:
platform :ios, '9.0'
use_frameworks!
target 'MapClusters' do
pod 'Alamofire'
pod 'SwiftyJSON'
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
end
Run Code Online (Sandbox Code Playgroud)
我试图删除pod 'Google-Maps-iOS-Utils'它确实有效.所以我猜Google-Maps-iOS-Utils是导致问题的原因之一.这是完整的错误:
[!] The 'Pods-MapClusters' target has transitive dependencies that include static binaries: (/Users/BAPS/Documents/Test/MapClusters/Pods/GoogleMaps/Subspecs/Base/Frameworks/GoogleMapsBase.framework, /Users/BAPS/Documents/Test/MapClusters/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMapsCore.framework, and /Users/BAPS/Documents/Test/MapClusters/Pods/GoogleMaps/Subspecs/Maps/Frameworks/GoogleMaps.framework)
Run Code Online (Sandbox Code Playgroud)
我已经在这里或网上的其他地方经历了很多答案.直到现在我已经尝试过这些解决方案:
禁用对传递依赖项的检查.
2.pre_install do |installer|
def installer.verify_no_static_framework_transitive_dependencies; end
end
post_install do |installer|
find Pods -regex 'Pods/GoogleMaps.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)GoogleMaps\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'
find Pods -regex 'Pods/Google-Maps-iOS-Utils.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)Google-Maps-iOS-Utils\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'
end
在Podfile中添加以上两点后,安装工作,但是当我尝试运行应用程序时,我收到此错误:

删除pod 'SwiftyJSON'它后,但我需要它.
我也尝试过其他一些东西,但似乎没有任何帮助.我是ios开发的新手,所以我无法自拔. …
google-maps-markers ios cocoapods google-maps-sdk-ios swifty-json
我正在iOS swift项目中使用谷歌地图.我想在地图上的两个位置之间绘制一条路径(非直线).知道怎么做吗?
我正在按照说明手动安装 GoogleMaps 和 GooglePlaces SDKs (v3.0.3),在拖动框架、添加到项目目标并复制捆绑资源后,项目成功构建但无法安装在模拟器上,如下所示错误:
Failed to load Info.plist from bundle at path
/Users/raphaeloliveira/Library/Developer/CoreSimulator/
Devices/DF9C1649-ED71-47D9-9E36-28F53FF59B24/data/Library/Caches/
com.apple.mobile.installd.staging/
temp.xSOM90/extracted/MyApp.app/Frameworks/GoogleMapsBase.framework
Run Code Online (Sandbox Code Playgroud)
下载的 zip 文件确实不包含框架文件夹中的 plist,这很奇怪。我注意到 GooglePlaces SDK 的捆绑资源确实包含一个 Info.plist 但这似乎还不够,即使在.framework/. 有没有人遇到过这种情况并找到了解决方案或解决方法?
PS:清理、删除派生数据、重新启动模拟器和 XCode 解决方法不起作用。
ios ×8
swift ×6
google-maps ×4
cocoapods ×1
ios7 ×1
mkmapview ×1
objective-c ×1
swifty-json ×1
xcode5 ×1