저는 iOS에서 새로운 기능이며 Google지도에서 여러 핀을 만드는 것과 관련하여 문제가 있습니다. 내 코드객관적인 C에서 Google지도에 동적으로 여러 개의 핀을 만드는 방법
//Google Maps...
_placesClient = [GMSPlacesClient sharedClient];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726
longitude:73.856255
zoom:3];
mapView = [GMSMapView mapWithFrame:CGRectMake(10, 140, 350, 350) camera:camera];
GMSMutablePath *path = [GMSMutablePath path];
[path addLatitude:18.516726 longitude:73.856255]; // Sydney
[path addLatitude:19.0728300 longitude:72.8826100]; // Fiji
mapView.delegate=self;
mapView.myLocationEnabled=YES;
locationtbl.hidden=YES;
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
//Configure Accuracy depending on your needs, default is kCLLocationAccuracyBest
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
// Set a movement threshold for new events.
locationManager.distanceFilter = 500; // meters
[locationManager startUpdatingLocation];
mapView.settings.myLocationButton = YES;
mapView.settings.scrollGestures = YES;
mapView.settings.zoomGestures = YES;
mapView.settings.tiltGestures=YES;
mapView.settings.rotateGestures=NO;
mapView.settings.compassButton = YES;
[self.view addSubview:mapView];
구글 위임 방법은 Google지도에 여러 개의 핀을 표시하는 방법이다 내가 문제를 직면하고이
#pragma mark - Google Maps
// Add a UIButton in Interface Builder to call this function
- (IBAction)pickPlace:(UIButton *)sender {
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(18.516726, 73.856255);
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(center.latitude + 0.001,
center.longitude + 0.001);
CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(center.latitude - 0.001,
center.longitude - 0.001);
GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast
coordinate:southWest];
GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
_placePicker = [[GMSPlacePicker alloc] initWithConfig:config];
[_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {
if (error != nil) {
NSLog(@"Pick Place error %@", [error localizedDescription]);
return;
}
if (place != nil) {
self.nameLabel.text = place.name;
self.addressLabel.text = [[place.formattedAddress
componentsSeparatedByString:@", "] componentsJoinedByString:@"\n"];
} else {
self.nameLabel.text = @"No place selected";
self.addressLabel.text = @"";
}
}];
}
같다)보기 DidLoad이
(과 같다. 동적 인 배열의 웹 서비스에서 가치를 얻고 있습니다. 이 이미지와 같이 Google지도에 을 표시해야합니다.
H는 Google지도에서 이미지로 생성되는 핀입니다. 어떻게해야합니까 ??
나는이
for (int i=0; i<NameHSArray.count; i++) {
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(18.516726, 73.856255);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = @"Hello World";
marker.icon = [UIImage imageNamed:@"mapicon1.png"];
marker.map = mapView;
}
과 같은 코드를 사용하지만 배열을 추가하고 때 그것은 나를 사전에
감사 오류 줘!
은이 코드를 사용하고는
for (int i=0; i<NameHSArray.count; i++) {
double LatitudeDouble = [LatitudeHSArray[i] doubleValue];
double LongitudeDouble = [LongitudeHSArray[i] doubleValue];
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(LatitudeDouble, LongitudeDouble);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = NameHSArray[i];
marker.icon = [UIImage imageNamed:@"mapicon1.png"];
GMSCameraUpdate *zoomCamera = [GMSCameraUpdate zoomIn];
[mapView animateWithCameraUpdate:zoomCamera];
marker.map = mapView;
}
문자열 값에 해당 마커 개체를 추가 할 하나를 기본하려는 경우와 위도 긴 위치를 전달하고 하나가있는 경우 아이콘 이미지를 할당 ... 또는 전무 배열에서 이것을 시도해보십시오 [[LattitudeHSArray objectAtIndex : 0] doubleValue] 배열에 double 값을 입력 한 다음 [LattitudeHSArray objectAtIndex : 0]을 사용하십시오 이것을 시도하십시오 –