Questions tagged [mapkit]

MapKit is Apple's framework for presenting and annotating scrollable and zoom-enabled maps on iOS, IPadOS, tvOS, watchOS, and macOS.

MapKit is Apple's framework for presenting and annotating maps for iOS, IPadOS, tvOS, watchOS, and macOS. Maps are rendered via the MKMapView control, which offers scrolling, zooming, and optionally real-time highlighting of the user's current location on both traditional maps as well as satellite imagery.

Maps can be further customized by:

  • Adding annotations (information about a point on the map), which can then be represented on the MKMapView using annotation views, graphical representations (such as a drop pin or a custom image). Annotations also may have associated attributes (such as text that can appear in a callout box that appears when you tap on an annotation view), and these callout boxes can also have additional behaviors (e.g. left and right accessory controls that you can use to perform custom operations, etc);

  • Adding overlays, graphical representations between a collection of map points (e.g. a MKPolyline that represents one or more line segments, such as a path, along the map; a MKPolygon that represents a shaded portion of the map defined by the coordinates of a polygon, a MKCircle that represents a shaded circle around a particular map point, etc.). Overlays are represented by MKOverlayView objects which define the particulars of how the overlay is represented (line thickness, line color, shading, etc.).

  • The Map Kit framework also provides local search capabilities (as of iOS 6.1, OS X 10.9), via MKLocalSearch, which will asynchronously return establishments and points of interest based upon the search criteria.

The reverse geocoding, via MKReverseGeocoder, is deprecated as of iOS 5.0, superseded by the CLGeocoder class of the Core Location framework

MapKit is part of the following SDKs:

  • iOS 3.0 and later,
  • macOS 10.9 and later,
  • Mac Catalyst 13.0 and later,
  • tvOS 9.2 and later,
  • watchOS 2.0 and later.

###Related tags:

###References:

5877 questions
2
votes
1 answer

MKPointAnnotation with image, insert annotation via Button, image doesn't appear

When I press my button, I want to add an annotation to my mapview. let annotation = MKPointAnnotation() annoation.coordinate = (myrightCoordinates) let annoationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "ident") …
kuzdu
  • 7,124
  • 1
  • 51
  • 69
2
votes
1 answer

(Swift 2.1) Load annotations for visible region in MKMapView

I am calling API and getting latitude, longitude, title and many other data and storing them into custom data structure. I get 20 results per request. So i need to show only some of those 20 results into visible area of MKMapView. When user change…
2
votes
1 answer

Apple sample project PhotoMap has a memory leak

I have encountered nasty memory leak in the Apple sample project. This is MapKit sample project which demonstrates how to do clustering. All you need to reproduce this is to spin map around, memory usage grows non stop until app crashes. You can…
Boris Y.
  • 4,387
  • 2
  • 32
  • 50
2
votes
2 answers

How to catch the click on the button in added XIB view (annotation)

1) I have the ViewController with the MapKit 1.1) I have added some pin's to Map class ViewController: UIViewController, MKMapViewDelegate 2) I write the new classes for custom pin Callout and Annotation class CustomPointAnnotation:…
GenRiH
  • 132
  • 2
  • 11
2
votes
1 answer

Fetch CloudKit records from current iCloud user

I want to fetch all of the location records from a user that is currently logged in. This creates the location record on CloudKit: func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let location =…
Tom Wicks
  • 785
  • 2
  • 11
  • 28
2
votes
1 answer

How to Register an App to Open a Location

We have an automotive app which we would like to open on location share - i.e. when a user tries to share a location inside Maps, a list of capable apps, such as Messenger, Viber, Mail etc. shows up. We have added capabilities, but we only show…
2
votes
2 answers

Using two different cells in tableview

I want to show two different maps in a tableview, and I have used this code previously, but now Xcode complains that the cell has no members nameLabel, addressLabel. Am I missing something? func tableView(tableView: UITableView,…
rebellion
  • 6,628
  • 11
  • 48
  • 79
2
votes
1 answer

get coordinates on tap in iphone application

I am create a iphone Mapkit application. I want to get the coordinates where the user has tapped on the map screen. Best Regards, Naveed Rafi
Naveed
  • 183
  • 1
  • 8
2
votes
0 answers

MKMapView setCenterCoordinate: not centering coordinate in view

I'm attempting to center a MKMapView on the coordinate of an annotation upon selection with mapView.setCenterCoordinate(annotation.coordinate, animated: true). However the map is instead (and consistently) placing the annotation about 100px…
eeeee
  • 224
  • 2
  • 10
2
votes
1 answer

UIPanGestureRecognizer never call action method

I'm trying to add a UIPanGestureRecognizer to my mapView but I don't why the action method is never called (Swift 2.1). import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate,…
Massimo Polimeni
  • 4,826
  • 4
  • 27
  • 54
2
votes
3 answers

How do I access the available data when I click an annotation?

I have several annotation points. What I want to do is when I click an annotation point I want to display that data. I have a custom Annotation class with a title and an NSDictionary. The dictionary contains an image URL and ID. I want to fetch…
Thejus
  • 169
  • 12
2
votes
2 answers

MKUserTrackingBarButtonItem in Mapbox

I'm evaluating switching from MapKit to Mapbox. I already found equivalents for all of my functions, except the MKUserTrackingBarButtonItem. let trackingButton = MKUserTrackingBarButtonItem(mapView: map) Is there a way to create this button for the…
dersvenhesse
  • 6,276
  • 2
  • 32
  • 53
2
votes
1 answer

how can I add an annotation view to the pin on my apple map while using marker clustering in swift?

I'm using a simple marker cluster taken from here https://github.com/ribl/FBAnnotationClusteringSwift and I see this part of code responsible for putting on the map either a cluster or a pin: func mapView(mapView: MKMapView!, viewForAnnotation…
user3766930
  • 5,629
  • 10
  • 51
  • 104
2
votes
1 answer

detailCalloutAccessoryView constraints in MKAnnotationView

i have some problems sizing a detailCalloutAccessoryView that i added programmatically. Here's the code for the view HCSStarRatingView *annotationRating = [[HCSStarRatingView alloc] init]; annotationView.detailCalloutAccessoryView =…
Muffin
  • 55
  • 6
2
votes
1 answer

Why is my MapKit callout view so small and not showing everything it needs to show?

SOLUTION I just had to apply constraints to make it work: let widthConstraint = NSLayoutConstraint(item: customCalloutView, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 200) …
Jack Berstrem
  • 535
  • 1
  • 5
  • 22