mapkit

Calculate area of MKPolygon in an MKMapView

淺唱寂寞╮ 提交于 2019-12-04 01:46:40
问题 I just don't know how to calculate the area on the MKMapView. Anyone who has solved this problem yet? This is my code, but it returns way too much: func ringArea() -> Double{ var area: Double = 0 if templocations.count > 2 { var p1,p2:CLLocationCoordinate2D for var i = 0; i < templocations.count - 1; i++ { var loc = templocations[i] as CLLocation p1 = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude) loc = templocations[i+1] as CLLocation p2 =

iOS MKDirections for multiple destinations and a single source

僤鯓⒐⒋嵵緔 提交于 2019-12-03 21:43:17
My application needs to get the "closest" walking point to the user from a set of 10. I have seen that MKDirections does this with "calculateDirectionsWithCompletionHandler" for a single source, destination locations. My question is, do I have do make 10 requests and then check which one is the closest one in distance or there is a way of sending multiple destinations and the response would be the closest one walking? Thank you As far as I'm aware there is no way to specify more than two points for an MKDirections request. Your proposed solution of creating 10 separate requests should work in

Check if user location is inside a shape

可紊 提交于 2019-12-03 21:31:14
I made this method to check if an user location is inside a polygon on a map view (mapkit). I pass to the method the current user location (CLLocationCoordinate2D) and return a boolean just to know if the user is in a polygon or not. func userInsidePolygon(userlocation: CLLocationCoordinate2D ) -> Bool{ // get every overlay on the map let o = self.mapView.overlays // loop every overlay on map for overlay in o { // handle only polygon if overlay is MKPolygon{ let polygon:MKPolygon = overlay as! MKPolygon let polygonPath:CGMutablePathRef = CGPathCreateMutable() // get points of polygon let

Query a GeoPoint from Parse and add it to MapKit as MKAnnotation?

久未见 提交于 2019-12-03 20:28:14
问题 I am trying to query an array of PFGeoPoints stored on the Parse backend. I have a PFObject in Parse called "Post", with data assigned to it such as "location", "title", "message", etc. everything is being sent to Parse upon posting from my app and is properly stored in the backend. I am having issues retrieving properties of the "Post" PFObject from Parse and storing them into an MKAnnotation on the map. Here is my MapViewViewController: import UIKit import Parse import CoreLocation import

iOS 6 Map problems with MKUserTrackingModeFollowWithHeading

放肆的年华 提交于 2019-12-03 20:21:39
I'm trying to solve two problems with MKUserTrackingModeFollowWithHeading in iOS 6: MKUserTrackingModeFollowWithHeading works briefly, but it's jittery and returns to MKUserTrackingModeFollow almost immediately, especially at high zoom levels. The app occasionally crashes when repeatedly changing the MKUserTrackingMode : I get EXC_BAD_ACCESS on the main thread, without further information. This is hard to reproduce, but it has happened repeatedly. Any thoughts on what might be causing this? It feels like a bug, but Apple's own "Maps" app doesn't exhibit this behavior. In order to isolate the

MapTypeStyle in MapKit

老子叫甜甜 提交于 2019-12-03 20:19:48
问题 I wonder to know if there is any way to configure our MapKit maps like we do with the MapTypeStyle object in the Google Maps API. If I refer to Apple doc's, MKMapView has a mapType option that takes MKMapType constant but no styles parameters like MapOptions with the MapTypeStyle and the MapTypeStyler wich is very powerfull for fast maps customizing. So my question is : Is there any way to achieve something similar with the MapKit framework, if not, what is the best framework/library to do

Map button refresh location

牧云@^-^@ 提交于 2019-12-03 20:15:37
问题 I am working on my first swift application for the iPad. Thus far I have a basic mapview with a button in the bottom toolbar, which I would like to refresh and focus onto the users location once clicked. Currently I have this code: import UIKit import MapKit import CoreLocation class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { var location: CLLocation! let locationManager = CLLocationManager() @IBOutlet weak var mapView: MKMapView! @IBOutlet weak var

Grouped/Ungroup MKAnnotation depending on the zoom level (And keep it fast)

旧城冷巷雨未停 提交于 2019-12-03 18:46:06
问题 I have a mapview that has a lot of annotations, most of them are very close to each other. What I want to do is similar to the Photo app on iOS where annotations are grouped when they are too close to each other and whenever you zoom out, they un grouped if they are too far apart. I have seen this question already but the answer given isn't really what I was looking for. I'm looking for either a library or a algorithm that I could implement myself. 回答1: Have a look here in order to see the

setNeedsDisplayInMapRect doesn't trigger new drawMapRect: call

北战南征 提交于 2019-12-03 18:00:29
问题 I'm using a custom MKOverlay/MKOverlayView to completely cover the Google basemap with my own tiles, which are loaded asynchronously. I follow the pattern of requesting unloaded tiles when I receive a canDrawMapRect:zoomScale: call to my overlay view (and returning FALSE in that case), then calling setNeedsDisplayInMapRect:zoomScale: once the tile is available. This all generally works, and appears to work perfectly in the simulator. However, on the device I sometimes get a 'hole' in the

MKAnnotationView with custom view and image view

拜拜、爱过 提交于 2019-12-03 16:34:47
In my Map application, instead of showing a pin, I want to show a colored background circle with image in it. The color of the background (which is shade of green in below image) circle is dynamic. It will look as in below image: I created TCircleView which draws the color in "drawRect" To show similar annotation, I created object of TCircleView and UIImageView and add them to MKAnnotationView object. Its looking good and visible as expected. But its not allowing to detect tap/touch to show the call out. I'm using the below code: - (MKAnnotationView *)mapView:(MKMapView *)mapView