mapkit

Cannot subscript a value of type '[NSObject : AnyObject]' with an index of type 'String'

╄→гoц情女王★ 提交于 2019-12-11 04:30:49
问题 I been getting errors on the snippet of code below. Every time I try to build it, the compiler complains: Cannot subscript a value of type '[NSObject : AnyObject]' with an index of type 'String' Here is the code, in all of its glory: import Foundation import MapKit enum LocationKey: String { case Latitude = "lat" case Longitude = "long" case Title = "title" } extension MKPointAnnotation { var propertyState: [NSObject: AnyObject] { get { return [ LocationKey.Longitude.rawValue as NSObject:

How to select apple default points of interest

妖精的绣舞 提交于 2019-12-11 04:28:22
问题 I have a question regarding to the default points of interest. I can show the default POIs using mapView.showsPointsOfInterest = true But I cannot tap on /select those POIs (restaurant, hotel, etc ..). All I want is that when I tap on it, I can get its info (long/lat, name ...) I tried different delegate methods, such as func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) and func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? but none of

How can I overlay a search bar over MapKit?

白昼怎懂夜的黑 提交于 2019-12-11 04:19:17
问题 How can I overlay a search bar over MapKit? I like how the new Google Maps application has a search box and buttons that hover over the map. See the image on the left: I'm not sure how to get this however as I have not been programming iOS for longer than a couple of weeks. Any ideas on how I could hover UI elements on top of each other with Storyboards/Objective-C? Presumably it's a navigation bar that has been made invisible but how is this done, and how is it the Map appears underneath it?

Different custom image for each pin

帅比萌擦擦* 提交于 2019-12-11 03:58:00
问题 This may sound like a generic question but I've only found answers if I want the same image for all my pins, which i don't. That's how i'm working right now : I have all my locations in an array of Locations (custom class with long, lat, name, pin name). in the viewdidLoad I loop that array and create my pins with every object found, see following code : for(int i = 0 ; i<[_locationList count] ; i++) { Location *item = [_locationList objectAtIndex:i]; CLLocationCoordinate2D coordinate;

Custom annotationView images revert to pins when clicked

时光毁灭记忆、已成空白 提交于 2019-12-11 03:11:27
问题 I'm displaying custom images on a map (instead of the default pins) using the code below. However, when I tap on an item (and the callout appears), the image reverts to the default red pin. How can I keep my custom image, even when the callout is displayed? - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinAnnotation = nil; if (annotation != mapView.userLocation) { static NSString *pinID = @"mapPin"; pinAnnotation =

iPhone: Get Selected zoom level of Google map

久未见 提交于 2019-12-11 02:56:25
问题 We need to get the current selected zoom level of MKMapView when user either zooms-in or zooms-out on the Google Maps using Mapkit. The solution we have tried is running fine on simulator but not on real device (iPhone 3GS having iOS 3.0.1). We need to get it running on iOS 3+ (including iOS 4) Following is the code we are using to get the zoom-level:- On zoom-in/out, Mapkit calls this delegate:- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated which in turns calls

setUserTrackingMode to MKUserTrackingModeFollow without changing zoom level

∥☆過路亽.° 提交于 2019-12-11 02:25:59
问题 At Apple Documentation of setUserTrackingMode:animated: it is stated that: Setting the tracking mode to MKUserTrackingModeFollow or MKUserTrackingModeFollowWithHeading causes the map view to center the map on that location and begin tracking the user’s location. If the map is zoomed out, the map view automatically zooms in on the user’s location, effectively changing the current visible region. My question, is there a way we can retain current zoom level on map, while setting the user

Is it possible to force MapKit to show all annotations without clustering?

╄→гoц情女王★ 提交于 2019-12-11 02:19:36
问题 I have two classes that both conform to MKAnnotation , and I was wondering, is there a way to force MapKit to not cluster the annotation when a user zooms out and display all annotations? 回答1: Set MKAnnotation's clusteringIdentifier to nil. e.g. class BikeView: MKMarkerAnnotationView { override init(annotation: MKAnnotation?, reuseIdentifier: String?) { super.init(annotation: annotation, reuseIdentifier: reuseIdentifier) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has

Setting Map Pin colour dynamically for iOS

泄露秘密 提交于 2019-12-11 01:59:41
问题 I parse an xml that contains the string 0 ,1 and 2. //For reference 0 = Green 1 = Red 2 = Purple I have a class that confirms to the MKAnnotaion that contains the below variables that are properties. CLLocationCoordinate2D coordinate; NSString *title; NSString *subtitle; MKPinAnnotationColor pinColor; This class is named MyAnnotation Now in the viewDidLoad of the map view I run a for loop to iterate over the parsed data like the below (locationArray holds this data and I pull out all the info

Direction of target annotation when outside of visible area

跟風遠走 提交于 2019-12-11 01:55:34
问题 I would like to show the direction images on all sides of the screen. E.g. if the target's location is the right side of user's location and is outside of the visible map area, then I want to add a direction image as shown on the picture below (The Green annotation is user's location, red one is the direction for the target, which is out of bounds of the screen): What is the standard approach to do this? 回答1: The simplest way is to place four "pointer" views above the map at each of the