mapkit

Swift obtain visible annotations/clusters shown in map

纵然是瞬间 提交于 2019-12-11 18:14:17
问题 I'm currently developing an app where I load user images as an annotation onto a map. Currently, I use an API to load images in viewForAnnotation for each image annotation and if the user has more than a few thousand photos, this image loading function is called every time and degrades performance significantly. Is there anyway I can obtain just the annotations which are shown on the map currently, i.e. only the annotations and clusters of annotations that are visible to the user? Apple's API

Objective-C add MKOverlay to map view animated fade in

我只是一个虾纸丫 提交于 2019-12-11 18:06:53
问题 I've been trying to add an MKOverlay to a map with animation. I'm trying to make it fade in when it's added and fade out when it's removed. Could this be done by created a custom overlay class or overlay view class? 回答1: On iOS 7 you could achieve this even with the new MKOverlayRenderer . It has an alpha property which you could animate by setting up a timer to repeatedly change its value and call setNeedsDisplayInMapRect:zoomScale: . 回答2: This is trickier in iOS 7 and above since the

Swift Offset for MKPointAnnotations for same location coordinates at different altitude range

假装没事ソ 提交于 2019-12-11 17:22:07
问题 I have had a problem earlier and that's been answered here. Further, I have one more question where in I tried an approach and that fails. I need to show two Annotations on a map, that has same location coordinates. Data comes from a service and I applied a logic to add an offset of 0.0001 to the locations with same latitude. (SO Answer) Now when I zoom-in/zoom-out, I am calculating the altitude using let updatedRadius = (mapView.camera.altitude)/1000 //in KM And then, I have the following to

class -(MyAnnotation annotation) was deallocated

◇◆丶佛笑我妖孽 提交于 2019-12-11 16:36:20
问题 An instance 0x11d0ce4b0 of class -(MyAnnotation annotation) was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same

Is there a way to draw under names in MKMapView?

坚强是说给别人听的谎言 提交于 2019-12-11 16:35:09
问题 I've looked at the many fine threads on how to draw routes on an MKMapView and didn't see anything on this. I want to be able to draw information (e.g. traffic flow imagery for routes, possibly annotations) over the map terrain but under road names and numbers etc. It seems likely that there's no way to do this since the map / road names aren't exposed as separate layers in the mapkit? It does sound like I could draw a route under road names but that's because I can use Apple's API for that

How to save Pin Annotation once app is closed (Swift)

泄露秘密 提交于 2019-12-11 16:25:51
问题 Currently, my app pins a location and that location is stores like so: func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { // Find location of user var userLocation:CLLocation = locations[0] as! CLLocation var latitude = userLocation.coordinate.latitude var longitude = userLocation.coordinate.longitude var latDelta:CLLocationDegrees = 0.01 var longDelta: CLLocationDegrees = 0.01 var span: MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)

Get Bounding Box from lat/long and distance

情到浓时终转凉″ 提交于 2019-12-11 16:16:46
问题 Im using twitter stream api for my ios project. Stream API has a location parameter. How can i get bounding box coordinates from user location(lat/long) and 1km distance ? Is there any API or tool in MapKit or mathematical functions ? Input (latitude = 37.785834, longitude = -122.406417) Distance = 1000 meter Output latMin: 37.789934 longMin : -122.416417 latMax: 37.787834 longMax : -122.396417 回答1: Yep, check out the functions in <MapKit/MKGeometry.h> like MKMetersPerMapPointAtLatitude() ,

How to get N number of coordinates around center coordinate and radius

半世苍凉 提交于 2019-12-11 15:53:02
问题 I got a center coordinate and a distance/radius, I need to get N number of coordinates from center using radius, for example how to get 12 coordinates of red dots in following image. 回答1: you can use the Great-circle_distance calculation to get the points. I first calculate the bearings from the center point needed then foreach loop them and pass them to the function. function destinationPoint($lat, $lng, $brng, $dist) { $rad = 6371; // earths mean radius $dist = $dist/$rad; // convert dist

How can I know if an annotation is already on the mapview

大城市里の小女人 提交于 2019-12-11 15:46:50
问题 I trying to add annotation pin to Mapview if and only if there is no such same pin already on mapview to avoid having multiple repeat annotations at the same location. Any one can show me help? 回答1: You can use mapView.view(for:) method. e.g. if (self.mapView.view(for: annotation) != nil) { print("pin already on mapview") } 回答2: The approach suggested by @Kosuke Ogawa would work. However it is not a good idea to rely on the UI determine application state. For eg: You most probably have a list

How 3D map visualizations on iOS using Mapbox

偶尔善良 提交于 2019-12-11 15:45:58
问题 I am trying to achieve to draw this in mapbox, came across https://docs.mapbox.com/ios/maps/examples/extrusions/ but nothing helpfull as I have the latitude and longitude, I want to draw the shape like the yellow shown below .but not sure where to start they are doing using three.js as mentioned here -----Update--- tried the below just able to render GEOJson in flat view, not the height. import UIKit import Mapbox class SignUpAccount: UIViewController, MGLMapViewDelegate { var mapView: