पर रोकें मैं एक मानचित्र के साथ एक ऐप विकसित कर रहा हूं जिसमें उपयोगकर्ता बहुभुज क्षेत्र खींच सकता है।एमके पोलिगॉन को नॉट्स
मेरा मुद्दा यह है कि यह संभव है कि यह नॉट्स के साथ बहुभुज ड्राइंग (छवि देखें) (मुझे नहीं पता कि गाँठ सही शब्द है)। मुझे बहुभुज को नॉट्स प्राप्त करने से रोकने का एक आसान तरीका नहीं मिला। संलग्न छवि के मामले में, मुझे छोटे कर्ल को हटाया जाना चाहिए और यहां तक कि रूपरेखा को भी
क्या आप इसे बनाने का कोई तरीका जानते हैं?
- (void)touchesBegan:(UITouch*)touch
{
CGPoint location = [touch locationInView:self.mapView];
CLLocationCoordinate2D coordinate = [self.mapView convertPoint:location toCoordinateFromView:self.mapView];
[self.coordinates addObject:[NSValue valueWithMKCoordinate:coordinate]];
}
- (void)touchesMoved:(UITouch*)touch
{
CGPoint location = [touch locationInView:self.mapView];
CLLocationCoordinate2D coordinate = [self.mapView convertPoint:location toCoordinateFromView:self.mapView];
[self.coordinates addObject:[NSValue valueWithMKCoordinate:coordinate]];
}
- (void)touchesEnded:(UITouch*)touch
{
CGPoint location = [touch locationInView:self.mapView];
CLLocationCoordinate2D coordinate = [self.mapView convertPoint:location toCoordinateFromView:self.mapView];
[self.coordinates addObject:[NSValue valueWithMKCoordinate:coordinate]];
[self didTouchUpInsideDrawButton:nil];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayPathView *overlayPathView;
if ([overlay isKindOfClass:[MKPolygon class]])
{
// create a polygonView using polygon_overlay object
overlayPathView = [[MKPolygonView alloc] initWithPolygon:overlay];
overlayPathView.fillColor = [UIColor redColor];
overlayPathView.lineWidth = 1.5;
return overlayPathView;
}
else if ([overlay isKindOfClass:[MKPolyline class]])
{
overlayPathView = [[MKPolylineView alloc] initWithPolyline:(MKPolyline *)overlay];
overlayPathView.fillColor = [UIColor redColor];
overlayPathView.lineWidth = 3;
return overlayPathView;
}
return nil;
}
वास्तव में, कोई भी मुझे बता सकते हैं ट्रैक जो मैं अपने बहुभुज के सिरों को सम करने के लिए का पालन कर सकता है? – Lisarien
कृपया एक कोड प्रदान करें जहां आप MKPolygon बना रहे हैं और इसे मानचित्र में जोड़ रहे हैं – ninjaproger