mapkit

Cannot wait for the result of MKDirections.calculate, getting nil instead of it

ぃ、小莉子 提交于 2020-03-23 12:03:36
问题 I would like to calculate the real walking distance between my current location and a list of CLLocation s using MKDirections.calculate . However, for some reason the return command at the end of the function does not wait for the result and tries to return the empty variable. My code looks like this: func getDistance (location1: CLLocation, location2: CLLocation) { let coordinates1 = location1.coordinate let placemark1 = MKPlacemark(coordinate: coordinates1) let sourceItem = MKMapItem

Subclasses of MKAnnotationView

喜夏-厌秋 提交于 2020-03-18 06:06:26
问题 I was wondering if anyone knows of any subclasses for the MKAnnotationView class. On apples documentation they say one example is the MKPinAnnotationView so I was wondering if there were other pre-created subclasses like the one used to track the devices current location. If anyone has tips for creating my own subclass of the MKAnnotationView class that be great as well. Thanks, bubster 回答1: I don't know of any other templates, but that does not mean that they don't exist. :) Anyway, here's

MapKit和CoreLocation

女生的网名这么多〃 提交于 2020-03-01 12:41:54
简介 现在很多的社交软件都引入了地图和定位功能,要想实现这两大功能,需要导入两个框架:MapKit和CoreLocation CoreLocation框架可以使用硬件设备来进行定位服务,不需要地图,精度相对略差,省电 MapKit框架能够使应用程序做一些地图展示与交互的相关功能,必须有地图,精度相对较高,费电 定位功能是所罗门(SoLoMo)应用的重要组成部分之一 几乎所有的iOS设备都支持位置服务,不过在使用位置服务之前,最好检查一下可用性 手机定位的三种方式:手机基站、WIFI、GPS 地图定位应该添加两个框架 #import <MapKit/MapKit.h> #import <CoreLocation/CoreLocation.h> 地图的类型 可以通过设置MKMapView的mapViewType设置地图类型 MKMapTypeStandard 普通地图 MKMapTypeSatellite 卫星云图 MKMapTypeHybrid 普通地图覆盖于卫星云图之上 MapView的代理 MapView会将一些事件传递给它的代理(遵守MKMapViewDelegate协议),代理方法如下: mapViewWillStartLoadingMap: 当地图界面将要加载时调用 mapView:viewForAnnotation: 当地图上有大头针时调用

Show MKPolyline on top of MapView when type is SatelliteFlyover?

。_饼干妹妹 提交于 2020-02-22 07:17:13
问题 I want to show a few MKPolylines on top of MapKit's mapView. The problem is when setting the map type to .satelliteFlyover my polylines will disappear. If I change to just using .satellite they're visible. mapView.type = .satelliteFlyover mapView.addOverlay(polyline) 来源: https://stackoverflow.com/questions/56917088/show-mkpolyline-on-top-of-mapview-when-type-is-satelliteflyover

Determining if Latitude/Longitude Point is in a MKPolygon within Mapview?

☆樱花仙子☆ 提交于 2020-02-18 05:05:10
问题 At this moment, I am trying to figure out whether a coordinate on a MKMapView is within a MKPolygon drawn out ahead of time with latitudes/longitudes. I am using CGPathContainsPoint to determine whether a coordinate is within the polygon on the map but it always returns false regardless of the coordinate I choose. Can anyone please explain what exactly is going wrong? Below is my code in Swift. class ViewController: UIViewController, MKMapViewDelegate @IBOutlet weak var mapView: MKMapView!

Size image pin annotation

冷暖自知 提交于 2020-02-18 05:01:26
问题 I put the personal image instead of the traditional red pin. When I open the map to display the pin, the image cover the entire map. Is there a maximum size of the pin image or how do I integrate something in the code to fit the size standard classic pin? func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { return nil } let annotationIdentifier = "SomeCustomIdentifier" // use something unique that functionally

Size image pin annotation

假如想象 提交于 2020-02-18 04:56:35
问题 I put the personal image instead of the traditional red pin. When I open the map to display the pin, the image cover the entire map. Is there a maximum size of the pin image or how do I integrate something in the code to fit the size standard classic pin? func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { return nil } let annotationIdentifier = "SomeCustomIdentifier" // use something unique that functionally

Xcode Error: Outlets cannot be connected to repeating content

早过忘川 提交于 2020-02-14 05:40:11
问题 After doing some searching and editing, I can't seem to find a solution to fixing this error. I'm trying to link my location search results with a table to display the search results in a list-form. I have my map with the details button linked with a UIViewController called 'FirstViewController.' My results table is linked with a UITableViewController called 'ResultsTableViewController.' My prototype cells are linked with a UITableViewCell called 'ResultsTableCell' which is also where my

Inverted Circle Overlay Not Showing On Map

戏子无情 提交于 2020-02-06 07:32:49
问题 I am trying to create a inverted MKCircle overlay on the map but it will not show up. Heres my inverted circle class code: import Foundation import MapKit class MKInvertedCircle : NSObject, MKOverlay { var coordinate: CLLocationCoordinate2D var boundingMapRect: MKMapRect { return MKMapRect.world } init(center coord: CLLocationCoordinate2D) { self.coordinate = coord } } Heres my inverted circle renderer class code: import Foundation import UIKit import MapKit class

Inverted Circle Overlay Not Showing On Map

你。 提交于 2020-02-06 07:32:29
问题 I am trying to create a inverted MKCircle overlay on the map but it will not show up. Heres my inverted circle class code: import Foundation import MapKit class MKInvertedCircle : NSObject, MKOverlay { var coordinate: CLLocationCoordinate2D var boundingMapRect: MKMapRect { return MKMapRect.world } init(center coord: CLLocationCoordinate2D) { self.coordinate = coord } } Heres my inverted circle renderer class code: import Foundation import UIKit import MapKit class