我正在尝试通过适用于iOS的Google Maps API从Google地图中显示自定义叠加视图.此叠加层查看标记的内容信息,以及两个我的按钮.但我找不到任何参考资料.我想要的叠加视图如下图所示:
http://i1121.photobucket.com/albums/l515/dungnlh_khtn07/NguoiMoCay/overlayinfoview_zps8110b7ed.jpg
请给我一个指南!
google-maps objective-c ios overlay-view google-maps-sdk-ios
有没有其他人经历过这个?我正在使用最新的Google Maps SDK for iOS.这就是我在didTapInfoWindowOfMarker方法中所拥有的:
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker {
NSLog(@"yes");
}
Run Code Online (Sandbox Code Playgroud)
在我的输出中没有得到任何响应.
我是一个新的谷歌地图sdk for ios.I在视图上添加了一个地图.当我输入这个mapView时,我想定位自己.所以我写道:
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
_iMapView = [GMSMapView mapWithFrame:CGRectMake(0, 0, 320, 480) camera:camera];
self.iMapView.myLocationEnabled = YES;
self.iMapView.delegate=self;
GMSMarkerOptions *annotation = [[GMSMarkerOptions alloc] init];
annotation.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
annotation.title = @"Sydney";
annotation.snippet = @"Australia";
//annotation.infoWindowAnchor=CGPointMake(0.5, 0.5);
[self.iMapView addMarkerWithOptions:annotation];
//[self.view addSubview:self.iMapView];
self.view=self.iMapView;
Run Code Online (Sandbox Code Playgroud)
但是我在坐标(33.8683,151.2086)中找到了mapView视图,我只想将mapView移动到wyposition.我也发现谷歌没有回调函数参考
self.iMapView.myLocationEnabled = YES;
谢谢你的回复.
我无法在目标C的谷歌地图上显示两个标记.我正在尝试将两个值传递给它.我意识到它可能只是被覆盖但我还没能解决它.请帮忙.这是来自.m文件的代码:
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position=CLLocationCoordinate2DMake(toLatitudeDouble, toLongitudeDouble);
marker.title=toLocationFromResultVC;
marker.snippet=@"Destination";
marker.position=CLLocationCoordinate2DMake(fromLatitudeDouble, fromLongitudeDouble);
marker.title=fromLocationFromResultVC;
marker.snippet=@"Source";
marker.map = mapView_;
Run Code Online (Sandbox Code Playgroud)
我需要提供更多细节吗?我很高兴能得到任何帮助.非常感谢!
正如标题所说,无论我给出什么坐标,我都会看到相同的位置.
这是我的代码:
我正在使用故事板,我的视图中有一个子视图.子视图的类型为GMSMapView,并且链接正确.
.H
@property (strong, nonatomic) IBOutlet GMSMapView *mymap;
Run Code Online (Sandbox Code Playgroud)
.M
@implementation DealViewController
{
GMSMapView *mapView_;
}
@synthesize mymap=_mymap;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view layoutIfNeeded];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, 300, 300) camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.mapType = kGMSTypeSatellite;
mapView_.delegate = self;
self.mymap=mapView_;
}
Run Code Online (Sandbox Code Playgroud)
我也试过这个,但我得到了同样的结果:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
Run Code Online (Sandbox Code Playgroud)
上面有什么问题?
我在使用适用于iOS的Google Maps SDK(版本1.5.0)绘制多个标记时遇到问题.我是目标c(使用Xcode版本4.6.3)和谷歌地图SDK的新手,所以我可能会遗漏一些明显的东西.我也在使用iOS 6.1模拟器.我正在努力学习.
我花了几天时间搜索并发现了几个涉及这个主题的线程,但没有一个解决方案适合我.我遇到的问题是我的标记会相互覆盖.我创建了一个NSArray,其中包含4列和未知行.列是纬度,经度,名称,地址.
for(int i=0;i<[locations count];i++){
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.0823
longitude:-74.2234
zoom:7];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.view = mapView_;
mapView_.myLocationEnabled = YES;
mapView_.mapType = kGMSTypeHybrid;
mapView_.settings.myLocationButton = YES;
mapView_.settings.zoomGestures = YES;
mapView_.settings.tiltGestures = NO;
mapView_.settings.rotateGestures = NO;
NSString *lat = [[locations objectAtIndex:i] objectAtIndex:0];
NSString *lon = [[locations objectAtIndex:i] objectAtIndex:1];
double lt=[lat doubleValue];
double ln=[lon doubleValue];
NSString *name = [[locations objectAtIndex:i] objectAtIndex:2];
NSMutableArray *markersArray = [[NSMutableArray alloc] init];
GMSMarker *marker = [[GMSMarker alloc] …Run Code Online (Sandbox Code Playgroud) 使用Google Maps IOS SDK,是否可以显示从一个位置到另一个位置的路线.我用谷歌搜索,但没有找到任何好结果.有什么建议?
我正在使用谷歌地图SDK构建iOS应用程序.当用户执行longPressAtCoordinate时,我可以在地图上添加一些标记.我的问题是,当我试图拖动一个标记时,diiLongPressAtCoordinate在didBeginDraggingMarker之前触发,因此也添加了一个新标记.
-(void)mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker{
NSLog(@"begin dragging marker");
}
- (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate (CLLocationCoordinate2D)coordinate{
NSLog(@"did long press at mapview");
//when user didLongPressAtCoordinate I add a new marker on the map.
// I want to prevent the execution of this code before the didBeginDraggingMarker method
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试首次将Google Maps SDK实施到我的iOS应用中.遵循Google的教程后,Google地图仍未显示在我的视图中.
这是我的AppDelegate代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("\(myAPIKey)")
return true
}
Run Code Online (Sandbox Code Playgroud)
这是我的View Controller中的代码,直接来自Google:
var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
longitude: 151.20, zoom: 6)
var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
mapsView = mapView
var marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
Run Code Online (Sandbox Code Playgroud)
但是,视图仍然没有显示出来.我检查了我的IBOutlet视图 - mapsView - 这是正确的.这是我的故事板的图像:
概述的空视图是我的地图视图.但这是我的应用程序在运行时的样子:
我知道有可能捕获标记的infowindow中的水龙头.我按照这里的文档.
所有都是写的,Objective C所以我尝试将其转换为Swift,这是我的代码:
func mapView(_ mapView: GMSMapView, didTap InfoWindowOfMarker: GMSMarker) {
print("You tapped infowindow")
}
Run Code Online (Sandbox Code Playgroud)
但这根本不会被解雇.这个方法有什么问题?