mapkit

iphone — convert MKMapPoint distances to meters

浪子不回头ぞ 提交于 2019-11-30 19:34:08
问题 Say I have a square which consists of four CLLocationCoordinate2D points, which are in lat, lon, and I want to find the area of the square in meters. I convert the CLLocationCoordinate2D points into MKMapPoints, and I find the area in X-Y space. However, the area I find is in the units of MKMapPoint, which don't directly translate to meters. How can I translate this area in MKMapPoint-space back into meters? 回答1: The MapKit function MKMetersBetweenMapPoints makes this easier. For example, if

How to display user location in mapkit?

一世执手 提交于 2019-11-30 18:51:57
问题 I'd like to display the blue pulsing dot for a user's location. I'm doing this: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ //some other stuff here [self.mapView setShowsUserLocation:YES]; } But I eventually get -[MKUserLocation establishment]: unrecognized selector sent to instance 0x125e90 Should I be doing this some other way? -- EDIT -- I'm also doing this, which is where I eventually get the

How to rotate custom userLocationAnnotationView image using MapKit in swift?

∥☆過路亽.° 提交于 2019-11-30 18:10:50
问题 I'm trying to find a way to show the direction of the user on the map using MapKit. The native MapKit way to do that always rotate the entire map. Since user position is also an MKAnnotationView, I decided to create a specific class to override it and use a specific image (with an arrow). class UserLocationAnnotationView: MKAnnotationView { override init(frame: CGRect) { super.init(frame: frame) } override init(annotation: MKAnnotation!, reuseIdentifier: String!) { super.init(annotation:

MKLocalSearch not finding obvious results

余生长醉 提交于 2019-11-30 17:59:26
问题 My code is virtually identical to the following example: https://github.com/iamamused/Example-MKLocalSearch.git Here are the important bits: @interface ViewController : UIViewController @property (strong, nonatomic) IBOutlet MKMapView *ibMapView; @end @implementation ViewController { MKLocalSearch *localSearch; MKLocalSearchResponse *results; } - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { [localSearch cancel]; MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc]

MapKit Entitlements Oddity

依然范特西╮ 提交于 2019-11-30 17:51:41
问题 I have a simple Mac app, not intended for distribution of any kind; simply personal use. The app is an NSWindow which contains an MKMapView . As I don't have a Mac dev account, and don't want one (see "personal use only"), I'm not doing any form of code signing or provisioning. However, on launch, I get a blank map and this error: Your Application has attempted to access the Map Kit API. You cannot access this API without an entitlement. You may receive an entitlement from the Mac Developer

iphone mapkit drag and get center location

萝らか妹 提交于 2019-11-30 17:50:10
问题 HI, I have a Mapview with some marker points + a marker for current location. Now, what I want to do here is, when user drag or traverse through mapview, I want to find coordinate (latitude, longitude) of the new center location after map has been dragged. I want to clarify once again, I am not talking about dragging the marker/point, I am talking about dragging the map with touch. Thanks in advance. 回答1: Look for theMapView.region.center or theMapView.centerCoordinate (should be the same) in

Accessing MKMapView elements as UIViewRepresentable in the main (ContentView) SwiftUI view

*爱你&永不变心* 提交于 2019-11-30 17:35:20
问题 I am using SwiftUI to display a map and if user tapped on an annotation, it pops up a detail view in the VStack. I have made the map view and inserted annotations in another SwiftUI file. I also made the detail view. How can I access the annotations of that map in the main view file to define a .tapaction for them to use it for the detailed view? I tried defining the view as MKMapView but it is not possible to do it for a UIViewRepresentable inside another SwiftUI view. The main view

Find out which type of area you are in from MKMapView

浪子不回头ぞ 提交于 2019-11-30 17:17:29
问题 is there any way to determine which type of area you are in from a MKMapView? I.e. if the centre of the map is in the ocean we can tell the user: the centre of the map is above the ocean, or if the map is centred above a green area: the centre of the map is above parkland... The only way I can think of to do this is to create a screenshot of the visible screen and analyse the colour of each bit by using some method such as this: iOS -- detect the color of a pixel? However I would be

MKMapview annotation dynamic pin image changes after zooming

安稳与你 提交于 2019-11-30 17:10:37
问题 I am working on a little project that shows 7 different types of annotations on the map. My annotations are taken from a url result in array and I parse it using JSON. I have lots of annotations and everything seems to look good once the map loads. After zooming in and zooming out, the the pin images changes for some reason to the wrong pin image (a specific image, no clue why). I am sure I am missing something here...may you please help :) ? Here's one part of my code, let me know if you

Can I use my own tiles in MapKit, instead of Google's?

醉酒当歌 提交于 2019-11-30 16:39:43
I'm currently trying to decide wether to accept a client's proposal or not. Basically, I'm asked to create a MapView that displays markers at several locations on a map, with the additional requirement that the client's own map tiles are used instead of Google Maps'. I do not know yet how the client stores their own map tiles, but I was assured that I'd be able to convert them into any format I'd need. Is it possible to use different map tiles in MapKit's MapView? Do you have good online literature about this? Links please? If this is possible, I'd propably have to create a server that sends