I'm using apple maps to build a feature so users can create and save running/cycling/hiking routes.
Currently the map only shows trails and similar local paths after zooming in to what is basically an extreme level.
I want the trails and local paths to be more visible on a further, broader level of zoom.
APPLE MAPS JS EX:
https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.17AM.png
https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.04AM.png
APPLE MAPS iOS EX:
https://trkbucket.s3.amazonaws.com/media/shoe_images/IMG_9DDF5C9A320D-1.jpeg
Also strange that on iOS the path is visible while more zoomed out whereas JS does not.
Please advise how to show these map items at a broader zoom.
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Post
Replies
Boosts
Views
Activity
I have an application that uses geolocation to track the user’s location and trigger actions when the app is in either the foreground or background. Currently, it seems that region entry is not triggered unless an app like Maps (which actively uses location services) is opened. The location permissions are correctly set to “Always” with precise location enabled.
We are using geofencing to setup region and trigger actions when entering or leaving.
Is there something I’m missing in the configuration that could be preventing region monitoring from triggering properly when the app is in use or in background?
mapView.showsTraffic=true
mapView.showsScale=true
mapView.showsCompass=true
mapView.showsUserLocation=true
mapView.showsBuildings=true
mapView.showsLargeContentViewer=true
hi,guy,please help to see this problem,thankyou,the mapkit api support some showsfunction,but I can not find how to show the exit of subway in my own app,but the map app of appple shows the exit of the subway,so how can I show the exit of the subway stations by using mapkit
I need some clarification on what is supposed to happen if the "allowsBackgroundLocationUpdates" flag on CLLocationManager is set to true, and only the "While in Use" permission has been given.
The customer I'm working with thinks that this combination should allow the app to receive location updates in the background indefinitely, as long as the app was in the foreground when we started receiving them.
What we've experienced is inconsistent. App updates do continue when the screen locks and in some cases when we switch to another app, but often they do not.
Our app doesn't require location updates 24/7, it requires them for a period of time when the user is performing an activity. The user starts and stops the activity in the app, and the activity might last up to a couple of hours. Can we do this using "While in Use" or do we need to request "Always" ?
My app has been using MKLocalSearch.Request for keyword-based location searches, and it has worked smoothly for a long time. However, starting last Wednesday, I began receiving an error from MKLocalSearch.start: MKErrorDomain (error code 4).
This issue only occurs when the network environment is based in mainland China (where the API uses the Amap data source). When the network switches to other regions and other Apple Maps data source is used, the error does not occur.
Another complication is that the API doesn't always fail—certain keywords still work (for example, "Huawei").
Already filed a ticket in Feedback Assistant: https://feedbackassistant.apple.com/feedback/15544549
I'm trying to use the new Apple Maps Server API. As far as I can tell I have set up the token correctly, but my web request is still returning 401 unauthorized.
The following is my code in TypeScript:
import * as jwt from 'jsonwebtoken';
const JWT_SECRET = "-----BEGIN PRIVATE KEY-----\n" +
"MIGTAgEAMBMGBy..............................\n" +
"..............................................................\n" +
"..............................................................\n" +
"-----END PRIVATE KEY-----";
const header = {
alg: "ES256",
kid: "26DYPK65ZK",
typ: "jwt"
}
// Example payload data
const payload = {
"iss": "7F3PBYWYMS",
"iat": Date.now(),
"exp": Date.now() + (1000 * 30 * 60),
};
export async function getRestaurants() {
let token = jwt.sign(payload, JWT_SECRET, { algorithm: 'ES256', header: header});
const response = await fetch('https://maps-api.apple.com/v1/token (https://maps-api.apple.com/v1/token)', {
method: 'GET',
headers: {
'Authorization': "Bearer " + token
},
});
console.log(response);
}
What am I doing incorrectly here?
I have an App which needs to monitor one CircularGeographicCondition for a feature. No other location services are required in the moment.
Im facing the problem that entry events aren't forwarded to my implementation in every case on real devices. In the simulator everything is working like a charm. Exit events seemed to be working quite reliable on real devices too.
Even after resuming the app from background in case of a missed entry event does not trigger the entry event. Only restarting (which recreates the monitor) triggers an entry event.
The radius of my geofence is 200 meters
What I have done:
a. Holding a service session
session = CLServiceSession(authorization: .always)
b. Creating a Task which holds the CLMonitor, adds the conditions and loops through the events.
My questions are:
Is this expected behavior?
If yes, how can I force the CLMonitor to recalculate the state of the condition?
Thank you so much for your help
aoubut MKLaunchOptionsDirectionsModeKey,
when I use MKLaunchOptionsDirectionsModeTransit as a mode in my code to call function openMaps ,the apple map app launches,it has 4 mode ,subbay or ferry,bus etc,so how can I specify the subway to transit before apple map app launch,so that I do not need to select on the map app,just specific subway in my own app, then the map app auto select the subway transit navigation。now it shows two much usless route。
MKLaunchOptionsDirectionsModeDefault
MKLaunchOptionsDirectionsModeDriving
MKLaunchOptionsDirectionsModeWalking
MKLaunchOptionsDirectionsModeTransit
when I am using the mapkit navigation, I only see the 4 modes, but can not find the mode of bicycle, so how can I find the enum of using bicycle to navigate by bicycle ,than you!~
Xcode version is 16.
hi, does someone encounter this problem, this is sample code :
let request = MKDirections.Request()
request.source = MKMapItem(placemark: startPlacemark)
request.destination = MKMapItem(placemark: endPlacemark)
request.transportType = .transit // .transit does not work
I want to make a route with two point(startPlacemark and endPlacemark ), when I give request.transportType the value of **.transit ** ,I found it not work, ps: .automobile .walking works well , my Xcode version is 16 .
A north american map that allows myself and family to drop pins and with those pins upload up to a min video to share w other users. This does not have to have navigation just a basic pin drop on a live map that uploads in real-ish time to share w other users ..... i am stuck at where to start, any suggestions or has anyone already made a version they could share advice ? much appreciated
I am using the code provided on the website https://developer.apple.com/maps/sample-code/embedded-map/index.html, replacing it with my own MapKit JS Token. When accessing it using a network in mainland China, a 401 error occurs with the message [Initialization failed because the authorization token is invalid]. However, it works normally when using a network in Japan. Does this service not work in mainland China?
Is there a way to obtain the information associated to multiple places at once? For example, instead of passing a single placeID, passing an array of placeIDs, and getting the basic info such as the name, the coordinates, etc.
This is my first post here. Please guide me, if I need to provide more information to answer this post.
I write a simple application, that monitors GPS position (location). I followed Apple documentation for LiveUpdates: https://developer.apple.com/documentation/corelocation/supporting-live-updates-in-swiftui-and-mac-catalyst-apps
My app can monitor location in foreground, background or it can completely stop monitoring location. Background location, if needed, is switched on when application changes scenePhase to .background. But it is in the foreground, that memory leaks occur (according to Instruments/Leaks. Namely Leaks points to the instruction:
let updates = CLLocationUpdate.liveUpdates()
every time I start location and then stop it, by setting updatesStarted to false.
Leaks claims there are 5x leaks there:
Malloc 32 Bytes 1 0x6000002c1d00 32 Bytes libswiftDispatch.dylib OS_dispatch_queue.init(label:qos:attributes:autoreleaseFrequency:target:)
CLDispatchSilo 1 0x60000269e700 96 Bytes CoreLocation 0x184525c64
Malloc 48 Bytes 1 0x600000c8f2d0 48 Bytes Foundation +[NSString stringWithUTF8String:]
NSMutableSet 1 0x6000002c4240 32 Bytes LocationSupport 0x18baa65d4
dispatch_queue_t (serial) 1 0x600002c69c80 128 Bytes libswiftDispatch.dylib OS_dispatch_queue.init(label:qos:attributes:autoreleaseFrequency:target:)
I tried [weak self] in Task, but it doesn't solve the leaks problem and causes other issues, so I dropped it. Anyway, Apple doesn't use it either.
Just in case this is my function, which has been slightly changed comparing to Apple example, to suit my needs:
func startLocationUpdates() {
Task() {
do {
self.updatesStarted = true
let updates = CLLocationUpdate.liveUpdates()
for try await update in updates {
// End location updates by breaking out of the loop.
if !self.updatesStarted {
self.location = nil
self.mapLocation = nil
self.track.removeAll()
break
}
if let loc = update.location {
let locationCoordinate = loc.coordinate
let location2D = CLLocationCoordinate2D(latitude: locationCoordinate.latitude, longitude: locationCoordinate.longitude)
self.location = location2D
if self.isAnchor {
if #available(iOS 18.0, *) {
if !update.stationary {
self.track.append(location2D)
}
} else {
// Fallback on earlier versions
if !update.isStationary {
self.track.append(location2D)
}
}
}
}
}
} catch {
//
}
return
}
}
Can anyone help me locating these leaks?
Hello.
I’m trying to use Core Location Service on any application in Mac (Safari, Maps, Weather, Chrome with Core Location configuration, or just trigger the API with a standalone app) and it seems that all of them constantly fail to provide the geolocation of my device because of the same error (kCLErrorLocationUnknown).
I'm using MacBook Pro (M3 Max) with Sonoma 14.7.
I’m sure the apps have access in the settings and everything is in order except the Core Location response.
I’ve tested the issue on multiple MacBooks and it reproduced 100% of the times on all of them.
Did anyone encounter a similar issue?
Hi everyone,
I’m encountering a strange issue with GPS tracking in my app, and I’m hoping for some insights.
I’m developing an app that records users' GPS activities (walking, biking, etc.) with app in the foreground and/or background. Most activities are outdoors, sometimes in areas with poor GPS reception, such as mountains.
To track user location, we’re using:
locationManager = CLLocationManager()
locationManager.distanceFilter = 3
locationManager.activityType = .fitness
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.allowsBackgroundLocationUpdates = true
The Issue
In certain scenarios, the GPS behaves unexpectedly.
For example (see attached image below):
A user followed a normal route (brown line), then reached an intersection and turned right (blue arrow). However, the GPS continued straight for about 200 meters (brown line) before correcting itself and resuming accurate tracking.
Here’s a snippet of the recorded coordinates during this misbehavior:
time,latitude,longitude,elevation,verticalAccuracy,horizontalAccuracy
10:17:17,47.92408,7.10438,950.82375,4.74865,4.80005
10:17:33,47.92410,7.10435,950.14966,4.74865,4.10799
10:17:44,47.92412,7.10431,943.63913,4.74865,4.46287
10:17:53,47.92413,7.10427,939.51380,4.74865,4.60644
10:17:59,47.92415,7.10424,934.82986,4.74865,4.52599
10:18:02,47.92417,7.10420,932.53145,4.74865,4.823035
10:18:05,47.92418,7.10416,927.84917,4.748655,4.59619
10:18:09,47.92420,7.10413,924.89886,4.748655,4.50172
10:18:13,47.92422,7.10409,923.35354,4.74865,4.77356
10:18:18,47.92424,7.104055,920.16327,4.74865,4.78286
10:18:22,47.92426,7.10400,915.23174,4.74865,4.66226
10:18:28,47.92427,7.10397,906.08626,4.74865,4.97331
10:18:31,47.92429,7.10394,903.25157,4.74865,4.81649
10:18:35,47.92431,7.10390,895.27948,4.74865,5.15392
10:18:38,47.92433,7.10386,889.71076,4.74865,5.25283
10:18:42,47.92435,7.10382,881.74041,4.74865,5.49089
10:18:46,47.92437,7.103785,874.34945,4.74865,5.55564
10:18:49,47.92439,7.10374,869.63184,4.74865,5.37537
10:18:53,47.92441,7.10370,861.26690,4.74865,5.39344
10:18:57,47.92443,7.10366,854.67646,4.74865,5.30404
10:19:01,47.92445,7.10362,848.48881,4.74865,5.59742
10:19:06,47.92447,7.10359,836.48915,4.74865,5.65666
10:19:08,47.92449,7.103555,835.72566,4.74865,5.54957
10:19:10,47.92450,7.10352,834.41579,4.74865,5.63540
10:19:13,47.92452,7.10348,830.17080,4.74865,5.65795
10:19:16,47.92454,7.10344,828.17052,4.74865,5.72169
10:19:19,47.92456,7.10340,824.93658,4.74865,5.62606
10:19:24,47.92458,7.10337,818.40503,4.74865,5.23265
10:19:34,47.92460,7.103335,804.42539,4.74865,4.683855
10:19:38,47.92462,7.10329,799.51747,4.74865,4.47590
10:19:48,47.92464,7.10324,784.97044,4.74865,4.59459
10:19:50,47.92466,7.10320,782.04750,4.748655,4.71036
10:19:57,47.92468,7.10317,777.49314,4.74865,4.60504
10:20:05,47.92469,7.10313,771.30168,4.74865,4.35574
10:20:09,47.92472,7.10308,766.64446,4.74865,4.94510
10:20:13,47.92474,7.10304,757.33384,4.74865,5.39175
10:20:15,47.92476,7.10300,753.52157,4.74865,5.442045
10:20:20,47.92477,7.10297,742.66179,4.74865,5.52391
10:20:23,47.92479,7.10293,735.38369,4.74865,5.44657
10:20:25,47.92480,7.10290,732.19367,4.74865,5.519945
10:20:28,47.92482,7.10286,725.15380,4.748655,5.58173
10:20:31,47.92484,7.10282,717.08813,4.74865,5.37805
10:20:34,47.92486,7.102785,710.35208,4.74865,5.27918
10:20:37,47.92488,7.10274,706.16774,4.748655,5.53270
10:20:40,47.92490,7.10270,702.84802,4.74865,5.71088
10:20:41,47.92648,7.10356,940.27115,6.600805,10.78768
10:20:43,47.92651,7.10355,940.24665,6.61807,10.45243
At 10:17:44, the location data was correct.
Shortly after, CLLocationManager started returning inaccurate coordinates. Despite the system reporting good horizontal and vertical accuracy, the altitude readings drop progressively from 940m to 702m, even though the user remained at 940m in reality. (We also recorded barometric elevation, which confirms that he stayed around 900m)
Then, at 10:20:41, the GPS corrected itself.
Questions
Is it possible that GPS could "lock onto" the wrong path, generating valid-looking but incorrect coordinates?
Can we force CLLocationManager to use GPS exclusively (disabling other sensors like Wi-Fi)? I assumed that setting activityType = .fitness would prioritize outdoor tracking, but I’m still being located indoors.
Could adjusting the activityType improve this behavior?
Could having multiple CLLocationManager() instances in our app cause issues? (We use one to save the GPS coordinates, but MapBox also creates a CLLocationManager with lower accuracy for its Telemetry framework, for example)
Thanks in advance for any help or suggestions!
I’m building an iOS app using MapKit that allows users to create and navigate trails. I need offline map functionality, I was wondering if MapKit supports that. If not I was wondering if MapBox is a viable alternative to MapKit though I would prefer using MapKit. Thanks!
Hi, in MapKit JS the hybrid view appears to have lost the street names overlay in the last few days. Does anyone know if this is an issue/error or a changed feature?
Thanks.
Hi,
Where can I get more information on expected behaviour for the liveUpdates() configuration options, .default, .automotiveNavigation, .fitness, .automotive, .otherNavigation?
Looking for expected accuracy, frequency of updates, non/stationary transition, etc.
Thanks
We are experiencing an issue where MKMapView appears red on the app builded with Xcode 16 and executed on iOS 18 simulator.
Only the ground is affected and buildings or POIs stay normal color.
Xcode 16.1 beta 3 shows same result.
Is there any similar case?