MapKit JS

No matter what I do I keep getting the error:


"Your location can only be shown when location services are enabled and your are connected to the Internet. Learn more"
On my computer and on my phone I keep getting the same error, both have everything enabled in location services, nothing is turned off.


Tried Safari, Chrome, Firefox in MacOS Mojave on a MacBook Pro with touch bar, as well as same 3 browsers in an iPhone XS Max with the latest iOS.


I followed "Intoducing MapKit JS" from WWDC and other online tutorials but nothing gives me my loacation, no matter if I am on WiFi or Celular. My GPS does work if I open the Maps app or Google Maps on both systems.


Any idea? I know is a beta but i wish it was better documented what is not working.

Replies

Is this the exact and complete message you receive ? It looks more like some text you typed in the post.


"Your location can only be shown when location services are enabled and your are connected to the Internet. Learn more"

There's a user-location-error event on the MapKit JS Map object. You could listen for this event to see what kind of error is being returned. The error codes for this event correlate to the error codes returned from the HTML5 Geolocation API, which is what MKJS uses under the hood to retrieve a user location.


You could also try retrieving location with the Geolocation API directly, to determine whether this is a problem with MKJS or something else on your system. Hope this helps, Ryuuzaki!

Is your site/page being served over HTTPS? Most (all?) current browsers only allow geolocation API access for secure origins.