我想显示我地图上的所有标记,经过一些搜索我发现它应该用GMSCoordinateBounds(Google Maps SDK)完成我已经阅读了有关它的官方文档,但我还不明白如何使用它并在我的代码中实现它.
这是我的代码
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
CLLocationCoordinate2D location;
for (NSDictionary *dictionary in array) {
location.latitude = [dictionary[@"latitude"] floatValue];
location.longitude = [dictionary[@"longitude"] floatValue];
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.icon = [UIImage imageNamed:(@"marker.png")];
marker.position = CLLocationCoordinate2DMake(location.latitude, location.longitude);
bounds = [bounds includingCoordinate:marker.position];
marker.title = dictionary[@"type"];
marker.map = mapView_;
}
[mapView_ animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:30.0f]];
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
我想显示用户位置的完整街道名称,下面的代码我只能显示城市名称:
-(void) reverseGeocode:(CLLocation *)location{
CLGeocoder *geocoder = [[CLGeocoder alloc]init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
if(error) {
NSLog(@"Error");
return;
}
if(placemarks) {
CLPlacemark *placemark = placemarks [0];
NSArray *lines = placemark.addressDictionary[ @"FormattedAddressLines"];
NSString *addressString = [lines componentsJoinedByString:@"\n"];
NSLog(@"Address: %@", addressString);
}
}];}
Run Code Online (Sandbox Code Playgroud)
关于如何获得街道名称的任何想法?
我想弄清楚这里出了什么问题,因为正如您在屏幕截图中可以看到的那样,为选定状态和默认状态提供了不同的图像。
当我在模拟器上运行时,我点击按钮,它显示高亮状态的图像,然后回到正常状态而不保持选择状态的变化!关于这个特定问题的任何提示或想法?


我尝试从Google Maps SDK中检索纬度和经度值,我正在使用它:
NSString *lati = [end_loc objectForKey:@"lat"];
NSString *longi = [end_loc objectForKey:@"lng"];
marker.position = CLLocationCoordinate2DMake(lati, longi);
Run Code Online (Sandbox Code Playgroud)
但在marker.position的行中,我收到此错误:
Passing 'NSString *__strong' to parameter of incompatible type 'CLLocationDegrees' (aka 'double')
Run Code Online (Sandbox Code Playgroud)
关于如何解决它的任何想法?