谷歌地图绘制多个标记问题(信息窗口和标记重复)
首先我创build一个用户位置的地图
-(void)initGogleMapView{ GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude zoom:1]; mapView = [GMSMapView mapWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64) camera:camera]; [self.view addSubview:mapView]; GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = camera.target; marker.appearAnimation = kGMSMarkerAnimationPop; marker.map = mapView; marker.title=@"Current Location"; }
然后我有一个经度和纬度的数组和循环的阴谋
for(int i=0;i<[latLongArr count];i++) { GMSMarker *tempmarker = [[GMSMarker alloc] init]; tempmarker.position = CLLocationCoordinate2DMake([[[latLongArr objectAtIndex:i] valueForKey:@"Latitude"] floatValue],[[[latLongArr objectAtIndex:i] valueForKey:@"Longitude"] floatValue]); tempmarker.title=[[latLongArr objectAtIndex:i] valueForKey:@"Name"]; tempmarker.appearAnimation = kGMSMarkerAnimationPop; tempmarker.map = mapView; }
标记重复相同的标题。任何人都可以帮助我,我在哪里做错了?
首先检查你的纬度和经度arrays,它可能是重复的。 否则,请执行以下步骤
首先,将GoogleMaps.bundle
和GoogleMaps.framework
添加到您的项目中。 然后当你想实现谷歌地图, #import <GoogleMaps/GoogleMaps.h>
,然后设置委托@interface YourViewController : UIViewController <GMSMapViewDelegate>
。
在.h
声明属性
@property (nonatomic, retain) GMSMapView *gMapView;
在viewDidLoad()
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:appDelegate.currentLoc.coordinate.latitude longitude:appDelegate.currentLoc.coordinate.longitude zoom:6]; self.gMapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; self.gMapView.delegate = self; self.gMapView.myLocationEnabled = YES; self.gMapView.mapType = kGMSTypeSatellite; self.view = self.gMapView; GMSMarker *curLocation = [[GMSMarker alloc] init]; curLocation.title = @"Current Location"; curLocation.appearAnimation = kGMSMarkerAnimationPop; curLocation.position = CLLocationCoordinate2DMake(appDelegate.currentLoc.coordinate.latitude, appDelegate.currentLoc.coordinate.longitude); curLocation.map = self.gMapView;
你在哪里添加了多个标记来映射。
for(int i=0;i<[latLongArr count];i++) { GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake([[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Latitude"] doubleValue], [[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Longitude"] doubleValue]); marker.appearAnimation = kGMSMarkerAnimationPop; marker.title = @"Title"; marker.snippet = @"Sub title"; marker.map = self.gMapView; }
- org.openqa.selenium.SessionNotCreatedException:无法创build新的会话。 (原始错误:请求新的会话,但正在进行中)
- 如何在iOS中正确地线性化OpenGL ES的深度?
- 如何在GoogleMaps for iOS中使用Firebase中的标记
- 自定义标记使用GMUClusterManager
- 迦太基和谷歌地图
- 移动地图时,Xcode 9模拟器上的GoogleMaps使用了超过100%的CPU
- 以相同的方式在GMSAutocomplete中使用textfield而不是searchbar
- 更新到IOS11和Xcode9后的问题! “com.google.Maps.LabelingBehavior”,“TIC Read Status”
- 使用Swift 3自定义视图中的Google Maps绘制折线
- 当使用谷歌方向Api和请求数据在JSON获取零数据
- iOS布局animation在GMSMapView拖动时忽略持续时间