Display map or satellite imagery from your app's interface, call out points of interest, and determine placemark information for map coordinates using MapKit.

MapKit Documentation

Posts under MapKit tag

124 Posts
Sort by:
Post not yet marked as solved
0 Replies
94 Views
Guys how is it possible to set a map type like hybrid, satellite etc on the following code? Thanks in advance! import MapKit struct MapView: View {         @State private var region: MKCoordinateRegion = {                  var mapCoordinates = CLLocationCoordinate2D(latitude: 6.600286, longitude: 16.4377599)         var mapZoomLevel  = MKCoordinateSpan(latitudeDelta: 70.0, longitudeDelta: 70.0)                  var mapRegion = MKCoordinateRegion(center: mapCoordinates, span: mapZoomLevel)         return mapRegion     } ()          let locations: [NationalParkLocation] = Bundle.main.decode("locations.json")     var body: some View {               Map(coordinateRegion: $region, annotationItems: locations, annotationContent: { item in                   MapAnnotation(coordinate: item.location) {                 Image("logo")                     .resizable()                     .scaledToFit()                     .frame(width: 32, height: 32, alignment: .center)             }                      })       } }
Posted
by xiouris.
Last updated
.
Post not yet marked as solved
0 Replies
155 Views
Hi All, I am trying to implement Alternate Routes using Mapkit in Swift. I am able to get the alternate route details but unable to handle the alternate route selection and drawing the polyline for the selected route. Can someone help me in achieving this some sample code snippet or references? Thanks in advance.
Posted Last updated
.
Post not yet marked as solved
0 Replies
198 Views
I want to see all the public transport stations on my MKMapView. With the following code I get train stations on the map: mapView.pointOfInterestFilter = MKPointOfInterestFilter(including: [.publicTransport]) But the bus stops are missing. If I use the Apple Maps app and chose Transit as the map, the bus stops are available there. How can I get the bus stops in my app using MKMapView?
Posted
by andre07.
Last updated
.
Post not yet marked as solved
1 Replies
159 Views
I have an MKRoute which I get from an MKDirections.Request. I want to change the coordinates of some points of the route. However, the polyline property of the route is get only. How can I do that?
Posted
by cnkgn1.
Last updated
.
Post not yet marked as solved
1 Replies
297 Views
With a Safari extension I add a link to certain websites to open the Maps app with coordinates found on the website. In the content script I detect clicks on my added link and forward the message to the background script with browser.runtime.sendMessage({ coordinates: "some coordinates I found on the website" }). The background script receives this message in its listener function and forwards the message to the extension handler like so browser.runtime.onMessage.addListener((request, sender, sendResponse) => { browser.runtime.sendNativeMessage( { message: request.coordinates }, function(response) { }); } The extension handler receives the message in its func beginRequest(with context: NSExtensionContext) function as expected. In this function I convert the coordinates I receive to a valid CLLocationCoordinate2D object. However, if I want to use the following code inside the beginRequest function to open the Maps app, it does not work on iOS. The same code works fine with a macOS Safari extension. MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 50.1234, longitude: 8.1234))).openInMaps()
Posted
by andre07.
Last updated
.
Post not yet marked as solved
1 Replies
280 Views
Failed to parse font key token is displayed at console. It doesn't particularly cause crashes, UI bugs, etc., but it is a concern. This is occurred when I zoom on SwiftUI Map. Part of code struct MapView: View { var body: some View {     Map(coordinateRegion: $viewModel.region,       showsUserLocation: true,       annotationItems: viewModel.pins,       annotationContent: { item in       MapAnnotation(coordinate: item.coordinate, anchorPoint: CGPoint(x: 0.5, y: 0.5), content: {         pinButton(pin: item)       })     })     .ignoresSafeArea()   } } My project is here.
Posted Last updated
.
Post not yet marked as solved
0 Replies
211 Views
I have a simple map made with "pure" SwiftUI. There is a search bar to search a place and when I click the "Go" button it shows the instructions of how to go that place from a particular location. It shows it below the map, on the "Enter a destination" field. What I want to do is, I want these instructions to be clickable. When I click each of the instructions it should zoom in that particular place where the instruction takes place. Right now it's only a list of text. Is it possible to do it without using UIViewRepresentable? And how can I do it? I tried with .onTapGesture { region.span = MKCoordinateSpan(latitudeDelta: region.span.latitudeDelta/2, longitudeDelta: region.span.longitudeDelta/2) } but it zooms in the same location on every instruction I click. ContentView let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } struct RouteSteps: Identifiable { let id = UUID() let step: String } struct ContentView: View { @State private var searchBar: String = "" @State private var home = CLLocationCoordinate2D(latitude: 39.90068, longitude: 32.86081) @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 39.90068, longitude: 32.86081), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)) @State var routeSteps: [RouteSteps] = [RouteSteps(step: "Enter a destination")] @State var annotations = [Location(name: "Ankara", coordinate: CLLocationCoordinate2D(latitude: 39.90068, longitude: 32.86081))] var body: some View { VStack{ HStack { TextField("", text: $searchBar) Button("Go") { findNewLocation() } .frame(width: 35, height: 35) .foregroundColor(Color.white) .background(Color.blue) .cornerRadius(5) }.textFieldStyle(.roundedBorder).colorInvert() Map(coordinateRegion: $region, annotationItems: annotations){ item in MapMarker(coordinate: item.coordinate) }.frame(width: 400, height: 300) List(routeSteps) { r in Text(r.step) } route function in ContentView func findNewLocation(){ let searchResult = searchBar let geocoder = CLGeocoder() geocoder.geocodeAddressString(searchResult, completionHandler: {(placemarks, error) -> Void in if((error) != nil){ print("error at geocode") } if let placemark = placemarks?.first { let coordinates : CLLocationCoordinate2D = placemark.location!.coordinate region = MKCoordinateRegion(center: coordinates, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)) annotations.append(Location(name: placemark.name!, coordinate: coordinates)) let request = MKDirections.Request() request.source = MKMapItem(placemark: MKPlacemark(coordinate: home, addressDictionary: nil)) request.destination = MKMapItem(placemark: MKPlacemark(coordinate: coordinates, addressDictionary: nil)) request.requestsAlternateRoutes = false request.transportType = .automobile let directions = MKDirections(request: request) directions.calculate(completionHandler: { response, error in for route in (response?.routes)! { self.routeSteps = [] for step in route.steps { self.routeSteps.append(RouteSteps(step: step.instructions)) } } }) } }) }
Posted
by _eda_.
Last updated
.
Post not yet marked as solved
3 Replies
1.3k Views
MKLocalSearch.start - https://developer.apple.com/documentation/mapkit/mklocalsearch/1452652-start is giving me MKErrorGEOError=-8 which is not documented in MKError - https://developer.apple.com/documentation/mapkit/mkerror. This only happens in my CI machine! This only happens when running the tests, the app code works fine I tried enabling location services on macOS just in case, but it didn't work. That machine shouldn't have any network requests/URLs blocked What fixed for me was to add request.naturalLanguageQuery = "Venue", but I don't understand why, nor why this would fix an error that is happening in only 1 machine. Does anyone have any information about this? Here's some sample code: let request = MKLocalSearch.Request() request.naturalLanguageQuery = "Venue" // this fixes it, but why?! let ibereCamargoMuseumCoordinates = CLLocationCoordinate2D(latitude: -30.0777596, longitude: -51.2477212) let span = MKCoordinateSpan(latitudeDelta: 5, longitudeDelta: 5) request.region = MKCoordinateRegion(center: ibereCamargoMuseumCoordinates, span: span) if #available(iOS 13.0, *) { request.resultTypes = .pointOfInterest } let localSearch = MKLocalSearch(request: request) localSearch.start { response, error in ... } Here's some debugging output: (lldb) po error Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8} (lldb) po error.userInfo ▿ 1 element ▿ 0 : 2 elements ▿ key : AnyHashable("MKErrorGEOError") - value : "MKErrorGEOError" value : -8 If you're interested I asked this on Stack Overflow - https://stackoverflow.com/questions/66976777/mklocalsearch-start-returning-undocumented-mkerrorgeoerror too.
Posted
by henrique.
Last updated
.
Post not yet marked as solved
0 Replies
235 Views
import UIKit import GoogleMaps class ReportLocationDetailViewController: UIViewController {     var event : ReportDetail?;          @IBOutlet weak var mapView: GMSMapView!;     @IBOutlet weak var zoomInBtn: UIButton!;     @IBOutlet weak var zoomOutBtn: UIButton!;          @IBAction func dismissAction(){         self.dismiss(animated: true) {                      }     }     @IBAction func zoomIn(){         self.mapView.animate(with: GMSCameraUpdate.zoomIn());     }          @IBAction func zoomOut(){         self.mapView.animate(with: GMSCameraUpdate.zoomOut());              }     func setUpUI(){         self.zoomInBtn.layer.cornerRadius = 2.0;         self.zoomInBtn.layer.masksToBounds = true;         self.zoomInBtn.layer.borderColor = UIColor.lightGray.cgColor;         self.zoomInBtn.layer.borderWidth = 1.0;         self.zoomInBtn.imageEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5);                  self.zoomOutBtn.layer.cornerRadius = 2.0;         self.zoomOutBtn.layer.masksToBounds = true;         self.zoomOutBtn.layer.borderColor = UIColor.lightGray.cgColor;         self.zoomOutBtn.layer.borderWidth = 1.0;         self.zoomOutBtn.imageEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5);     }          override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews();         self.setUpUI();     }          override func viewDidLoad() {         super.viewDidLoad()         UIView.appearance().semanticContentAttribute = .forceLeftToRight     }          override func viewDidAppear(_ animated: Bool) {         super.viewDidAppear(animated);         if let e = self.event, let lat = e.lat, let lon = e.lon{             let position = CLLocationCoordinate2D(latitude: lat, longitude: lon)             let marker = GMSMarker(position: position);             marker.snippet = e.address;             marker.title = e.name;             marker.groundAnchor = CGPoint(x: -6.5, y: -3.0);             marker.map = mapView;             self.mapView.selectedMarker = marker;             let update = GMSCameraUpdate.setTarget(position, zoom: 15)             self.mapView.animate(with: update);         }     } } Map view with correct position MapView After Zoom In MapView After Zoom Out
Posted Last updated
.
Post not yet marked as solved
0 Replies
210 Views
Hello everyone, I try to use the URL to generate a snapshot. Team ID and Key ID could be easily added. But how do I sign the signature? With what tool or website? I tried to sign it with openssl and several tool thar should be able to sign SHA-256 https://snapshot.apple-mapkit.com/api/v1/snapshot?center=apple+park&teamId=TEAM_ID&keyId=KEY_ID&signature=THE_SIGNATURE_HERE Kind regards, Jens
Posted
by Jens-Koch.
Last updated
.
Post not yet marked as solved
2 Replies
779 Views
Togther with MKMapSnapshotter, Mapkit provides all the tools to create animations, respectively image sequences.For example:https://youtu.be/yub8oVTA2fwFor this example the heading property of the mkMapCamera was animated. The movementof the camera looks smooth. (That's fine)In the next example the MKMapView.centerCoordinate was animated.https://youtu.be/QY7Pmg5oE2MYou may have noticed the jumps during the movement of the camera. (That's bad)The MKMapView.camera gets automatic updates.(Animation of the MKMapCamera.centercoordinate directlyhas the same effect) The jumps may rely on the MKMapCamera.altitude property. Because every change in centercoordinate the altitude of the camera is also updated.Altitude is defined as meters above ground and consequently the camera seems to follow the mapssurface. Interestingly, if the animation is made with mapkits own animator, it ispossible to move from A to B without height-changes.https://youtu.be/x7SzU20BJPM(The example was made with a NSView-Screencapture)Unfortunately the snapshotter cannot be used to get the frames because the camera is updated during snapshot-options preparation. This causes (?)also a correction (or reset) of the altitude property and thus the jump in the animation.So here is my question/suggestion.Would it be nice to have a MKMapCamera.aboveMeanSeaLevel property?Is there a workaround to get a moving camera in altitude above sea-level, i.esuppressing the altitude update?Thanks for any suggestions!
Posted
by nikkin.
Last updated
.
Post marked as solved
1 Replies
392 Views
And here is a snippet of the GeoJSON structure I am trying to build an app that shows some areas(polygons/overlays) on the map and when a polygon is tapped I would like to print on console print("Polygon \(zone_id) has been tapped"). The polygons are rendered from a GeoJSON file where we can also find the zone_id in the properties feature. So far I rendered the overlays on the map but I am stuck and I appreciate some guidance where to go from here. I will paste my code that I have so far and also a snippet of the GeoJSON file. import SwiftUI import CoreLocation struct Home: View {       @StateObject var mapData = MapViewModel()       var body: some View {     ZStack{               MapView()         .environmentObject(mapData)         .ignoresSafeArea(.all, edges: .all)               }   } } struct Home_Previews: PreviewProvider {   static var previews: some View {     Home()   } } import SwiftUI import MapKit struct MapView: UIViewRepresentable {       @EnvironmentObject var mapData: MapViewModel       @State var restrictions: [MKOverlay] = []       func makeCoordinator() -> Coordinator {     return MapView.Coordinator()   }       func makeUIView(context: Context) -> MKMapView {           let view = mapData.mapView           view.showsUserLocation = true     view.delegate = context.coordinator           mapData.showRestrictedZones { (restrictions) in       self.restrictions = restrictions       view.addOverlays(self.restrictions)     }     return view   }       func updateUIView(_ uiView: MKMapView, context: Context) {         }       class Coordinator: NSObject, MKMapViewDelegate {           func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {       if let polygon = overlay as? MKPolygon {         let renderer = MKPolygonRenderer(polygon: polygon)         renderer.fillColor = UIColor.purple.withAlphaComponent(0.2)         renderer.strokeColor = .purple.withAlphaComponent(0.7)                   return renderer       }       return MKOverlayRenderer(overlay: overlay)     }   } } import SwiftUI import MapKit // All Map Data Goes here... class MapViewModel: NSObject, ObservableObject {       @Published var mapView = MKMapView()              // Decode GeoJSON from the server   func showRestrictedZones(completion: @escaping ([MKOverlay]) -> ()) {     guard let url = URL(string: "https://flightplan.romatsa.ro/init/static/zone_restrictionate_uav.json") else {       fatalError("Unable to get geoJSON") }           downloadData(fromURL: url) { (returnedData) in       if let data = returnedData {         var geoJson = [MKGeoJSONObject]()         do {           geoJson = try MKGeoJSONDecoder().decode(data)         } catch {           fatalError("Unable to decode GeoJSON")         }         var overlays = [MKOverlay]()         for item in geoJson {           if let feature = item as? MKGeoJSONFeature {             for geo in feature.geometry {               if let polygon = geo as? MKPolygon {                 overlays.append(polygon)                                 }             }           }         }         DispatchQueue.main.async {           completion(overlays)         }       }     }   }       func downloadData( fromURL url: URL, completion: @escaping (_ data: Data?) -> ()) {     URLSession.shared.dataTask(with: url) { (data, response, error) in       guard         let data = data,         error == nil,         let response = response as? HTTPURLResponse,         response.statusCode >= 200 && response.statusCode < 300 else {         print("Error downloading data.")         completion(nil)         return       }       completion(data)     }     .resume()   } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
1k Views
Hi, I'm trying to add overlays to my map and I can't seem to make it happen. I get an error message in the console only when I add mapView.addOverlay(overlay) in my makeUIView What is weird is that I still make it to the Coordinator func rendererFor overLay, because I sent a print() which is read inside the if statement I get this message running it on simulator I get this running on iPhone, but with no overlay on my map Thanks for any help import SwiftUI import MapKit struct MKMap: UIViewRepresentable {       @ObservedObject var vm: MapViewModel = MapViewModel.shared   let mapView = MKMapView()   func makeCoordinator() -> Coordinator {     Coordinator(self)   }           // This funciton is called when we make the view   func makeUIView(context: Context) -> MKMapView {           mapView.delegate = context.coordinator     mapView.userLocation.title = "user"     mapView.showsUserLocation = true     let point = CLLocationCoordinate2D(latitude: -73.68118286132812, longitude: 45.48589125320114)     let overlay = MKCircle(center: point, radius: 30)     mapView.addOverlay(overlay)           let region = MKCoordinateRegion(center: vm.center, span: vm.span)     mapView.setRegion(region, animated: true)           return mapView   }       // Function called when the view is updated   func updateUIView(_ uiView: MKMapView, context: Context) {   } } class Coordinator: NSObject, MKMapViewDelegate, CLLocationManagerDelegate{   var parent: MKMap   init(_ parent: MKMap){     self.parent = parent         }           func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {           if overlay is MKCircle{       print("--->>> I'm inside the rendererFor overlay in MKCircle Statement <<<---")       let renderer = MKCircleRenderer(overlay: overlay)       renderer.lineWidth = 100       return renderer     }     return MKOverlayRenderer()   } }
Posted
by jmarc101.
Last updated
.
Post not yet marked as solved
5 Replies
1k Views
I have an standard Open Street Map Overlay implemented. It works perfect on the Simulator and when I set explicitly canReplaceMapContent to YES on the overlay. If I set it to NO, it will not display on any iOS 14 device. iOS 13 devices were able to display it. I develop the app in Objective C, the overlay was working for many iOS releases before. Standard MKTileOverlay, standard URL tile.openstreetmap.org: &#9;_tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:@"https://<OSM URL>/{z}/{x}/{y}.png"]; &#9;_tileOverlay.canReplaceMapContent = NO; &#9;[_mapView addOverlay:_tileOverlay level:MKOverlayLevelAboveLabels]; Standard MKTileOverlayRenderer: (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay { &#9;if ([overlay isKindOfClass:[MKTileOverlay class]]) { &#9;&#9;return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay]; &#9;} Having to set canReplaceMapContent to YES on the tile overlay leads to some flickering, which would be easy to avoid setting it to NO, but setting NO leads to only grey tiles, resp. no tiles drawn at all. Any ideas?
Posted Last updated
.
Post not yet marked as solved
3 Replies
1.5k Views
Hi guys. I just started developing my own apps and I am very new to Swift and development for iOS, but I had an idea for a great app that utilizes the "Look around" feature that Maps provide, but I can't find any information about this in the documentation for MapKit. Does anyone know if it currently possible to enable a view for this? Thanks in advance!
Posted
by Halallica.
Last updated
.
Post not yet marked as solved
0 Replies
218 Views
Updating my stack trace from Firebase Crashlytics here Crashed: com.apple.mapdisplay.dispatch.overlaytiledecodequeue 0  libobjc.A.dylib                0x21a0 objc_msgSend + 32 1  MapKit                         0xa990 -[MKOverlayRenderer overlay:canDrawKey:] + 56 2  VectorKit                      0x3c9090 _processOverlays(geo::MercatorTile const&, unsigned int, float, VKSharedResources const*, ggl::Loader&, std::__1::vector<geo::_retain_ptr<VKOverlay*, geo::_retain_objc, geo::_release_objc, geo::_hash_objc, geo::_equal_objc>, std::__1::allocator<geo::_retain_ptr<VKOverlay*, geo::_retain_objc, geo::_release_objc, geo::_hash_objc, geo::_equal_objc> > > const&, std::__1::vector<md::OverlayTileData::OverlayTileResource, std::__1::allocatormd::OverlayTileData::OverlayTileResource >&, std::__1::shared_ptr<ggl::ConstantDataTypedggl::Tile::View >) + 2716 3  VectorKit                      0x3c8418 md::OverlayLayerDataSource::createLayerData(mdc::LayerDataRequestKey const&, geo::linear_map<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > >, std::__1::equal_to, std::__1::allocator<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > > >, std::__1::vector<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > >, std::__1::allocator<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > > > > > const&, long long) const + 372 4  VectorKit                      0x5fd1a0 mdc::LayerDataSource::updateLayerData(unsigned long, mdc::LayerDataRequestKey const&, geo::linear_map<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > >, std::__1::equal_to, std::__1::allocator<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > > >, std::__1::vector<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > >, std::__1::allocator<std::__1::pair<unsigned short, std::__1::unordered_map<mdc::ResourceKey, std::__1::shared_ptrmdc::Resource, mdc::ResourceKeyHash, std::__1::equal_tomdc::ResourceKey, std::__1::allocator<std::__1::pair<mdc::ResourceKey const, std::__1::shared_ptrmdc::Resource > > > > > > > const&, long long) + 92 5  VectorKit                      0x600d80 std::__1::__function::__func<mdc::LayerDataSource::processLayerDataRequests(mdc::ResourceManager*, geo::TaskGroup*, long long)::$_5, std::__1::allocator<mdc::LayerDataSource::processLayerDataRequests(mdc::ResourceManager*, geo::TaskGroup*, long long)::$_5>, void ()>::operator()() + 156 6  VectorKit                      0x58090c invocation function for block in geo::TaskQueue::queueAsyncTask(std::__1::shared_ptrgeo::Task, NSObject<OS_dispatch_group>*) + 80 7  libdispatch.dylib              0x5b610 _dispatch_call_block_and_release + 24 8  libdispatch.dylib              0x5c184 _dispatch_client_callout + 16 9  libdispatch.dylib              0x8464 _dispatch_lane_serial_drain$VARIANT$mp + 608 10 libdispatch.dylib              0x8e88 _dispatch_lane_invoke$VARIANT$mp + 468 11 libdispatch.dylib              0x12340 _dispatch_workloop_worker_thread + 588 12 libsystem_pthread.dylib        0xbfa4 _pthread_wqthread + 276 13 libsystem_pthread.dylib        0xeae0 start_wqthread + 8
Posted
by Sathriyan.
Last updated
.
Post not yet marked as solved
0 Replies
401 Views
convert UIImage to CIImage,, but lose every element. position, rotate, scale etc.. i implemented video editor. so i add pan, rotate, pinch gesture event with UIImageVIew. and when i save video, i convert UIImageView to CIImage. but it's lose everything.. please help me...... ==========.        CIFilter *filter = [CIFilter filterWithName:@"CIAdditionCompositing"];       UIImageView *imageView = self.subviews[0];       CIImage *ciImage = [CIImage imageWithCGImage:imageView.image.CGImage];               _playerItem.videoComposition = [AVVideoComposition                       videoCompositionWithAsset:_playerItem.asset                       applyingCIFiltersWithHandler:^(AVAsynchronou sCIImageFilteringRequest *_Nonnull request) { if (filter == nil) {                        } else {                          CIImage *image = request.sourceImage.imageByClampingToExtent;                          [filter setDefaults];                          [filter setValue:image forKey:@"inputBackgroundImage"];                          [filter setValue:ciImage forKey:@"inputImage"];                                                     CIImage *outputImage = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];                                                     [request finishWithImage:outputImage context:nil];                        }                       }
Posted
by sangwonyu.
Last updated
.
Post not yet marked as solved
10 Replies
1.7k Views
I need to remove a Polyline and replace it by a new one on my mapView about every 2 seconds. The Polyline is correctly removed and added to the screen so that is great. But I see the app memory use increase by about 5 mb per minute. This results in the app becoming very slow and unresponsive. I see the problem on the IOS 14.2 simulator and hardware (iPhone and iPad). On my 13.4 simulator this problem does occur and all works fine without memory leaking. Below run the the steps to reproduce in a loop: 1 create a regular polyLine with about 50 entries polyLine.title = "polyLine" 2 mapView.addOverlay(PolyLine) 3 let allOverlays = mapView.overlays for overlay in allOverlays { if (overlay.title == "polyLine") {     mapView.removeOverlay(overlay)   } } 4 mapView.addOverlay(PolyLine) Note: I see the same problem when navigation routes (that is also using Polyline overlay) are recreated. So it looks like MapView graphically works ok but is not releasing memory after mapView.removeOverlay(overlay) is called. Here is some output from instruments/leaks pointing to VectorKit: MTLSimTexture 4048 < multiple > 1,48 MiB MTLSimDriver _77-[MTLSimTexture newTextureViewWithPixelFormatInternal:isInternalTextureView:]block_invoke Malloc 16 Bytes 4083 < multiple > 63,80 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long) Malloc 144 Bytes 4105 < multiple > 577,27 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long)
Posted
by henrivb.
Last updated
.
Post not yet marked as solved
0 Replies
291 Views
Hey guys, I was just learning the SwiftUI Tutorials, and I was quite confused about the Map preview in the following code: import SwiftUI import MapKit struct MapView: View {   var coordinate: CLLocationCoordinate2D   @State private var region = MKCoordinateRegion()   func setRegion(_ coordinate: CLLocationCoordinate2D) {      region = MKCoordinateRegion(       center: coordinate,       span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)     )   }       var body: some View {       Map(coordinateRegion: $region)         .onAppear {           setRegion(coordinate)       }   } } struct MapView_Previews: PreviewProvider {   static var previews: some View {     MapView(coordinate: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166868))   } } As you see, the preview shows a map of blue sea, instead of what I would like to see (the location of Joshua Tree). However, when I use MapView() in another view structure by embedding it within a HStack (VStack, ScrollView works as well ), the preview shows perfectly what I want: import MapKit struct MapViewDemo: View {   var body: some View {     HStack {       MapView(coordinate: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166868))     }   } } struct MapViewDemo_Previews: PreviewProvider {   static var previews: some View {     MapViewDemo()   } } Could you help me understand why it works this way? Is it the particular way how Map or .onAppear works?
Posted
by Chuqin.
Last updated
.
Post not yet marked as solved
2 Replies
354 Views
I am currently trying to create a map. However a bunch of errors keep showing up. What I am doing wrong and how would I be able to fix this?
Posted Last updated
.