0
iOS Googleマップを開発中です。私は次のことを除いて、ユーザーがマーカーをドラッグすると、マーカーが一度解放されても描画されないという点を除いて動作します。私はどこで間違いを犯したのですか?ドラッグしたときにマーカーが追加されない - GoogleマップiOSアプリ
- (void)clearAllOverlay
{
[_mapView clear];
[self drawPolygon];
[self addMarker];
}
- (void)addMarker
{
CLLocationCoordinate2D position;
for (int i = 0; i <= [tappedCoordinates count]-1; i++) {
position.latitude = [[[tappedCoordinates objectAtIndex:i] objectAtIndex:0] floatValue];
position.longitude = [[[tappedCoordinates objectAtIndex:i] objectAtIndex:1] floatValue];
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = position;
marker.map = _mapView;
marker.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]];
[marker setDraggable: YES];
}
}
//runs everytime user taps on marker
- (bool)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *) marker
{
[latitudeTappedCoordinates removeObject:[NSNumber numberWithFloat:marker.position.latitude]];
[longitudeTappedCoordinates removeObject:[NSNumber numberWithFloat:marker.position.longitude]];
[self clearAllOverlay];
return 0;
}
//called while marker is dragged
- (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *) marker
{
[latitudeTappedCoordinates addObject:[NSNumber numberWithFloat:marker.position.latitude]];
[longitudeTappedCoordinates addObject:[NSNumber numberWithFloat:marker.position.longitude]];
[self clearAllOverlay];
}
//runs everytime user taps on any coordinate, except marker
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
// store tapped coordinates in multi-dimensional array
NSArray *array = @[[NSNumber numberWithFloat:coordinate.latitude], [NSNumber numberWithFloat:coordinate.longitude]];
[tappedCoordinates addObject:array];
[latitudeTappedCoordinates addObject:[NSNumber numberWithFloat:coordinate.latitude]];
[longitudeTappedCoordinates addObject:[NSNumber numberWithFloat:coordinate.longitude]];
[self clearAllOverlay];
}
は、作業する必要がありますが、それはしていません。 – konyv12