Friday, 15 February 2013

coordinates - KMLViewer in iOS -



coordinates - KMLViewer in iOS -

i testing apple's kmlviewer software , wondering if utilize find in country x,y coordinates belongs. kml file has info countries. (polygons, overlay..).

if you've created mkpolygon overlays, , mkmapview has created mkpolygonview views in mapview:viewforoverlay:, , if you're trying see if tap gesture in particular mkpolygonview, think can following:

- (void)handletap:(uitapgesturerecognizer *)gesture { bool success = no; cgpoint location = [gesture locationinview:self.mapview]; cllocationcoordinate2d coordinate = [self.mapview convertpoint:location tocoordinatefromview:self.mapview]; mkmappoint mappoint = mkmappointforcoordinate(coordinate); (id<mkoverlay> overlay in self.mapview.overlays) { mkoverlayview *overlayview = [self.mapview viewforoverlay:overlay]; if ([overlayview iskindofclass:[mkpolygonview class]]) { mkpolygon *polygon = (mkpolygon *)overlay; mkpolygonview *polygonview = (mkpolygonview *)overlayview; cgpoint polygonviewpoint = [polygonview pointformappoint:mappoint]; if (cgpathcontainspoint([polygonview path], null, polygonviewpoint, no)) { nslog(@"overlay '%@' contains point %@", polygon.title, nsstringfromcgpoint(location)); success = yes; break; } } } if (!success) nslog(@"no overlays contained point %@", nsstringfromcgpoint(location)); }

ios coordinates kml polygon

No comments:

Post a Comment