Using Cordova Geolocation from Ionic APP

It appears that google has changed its security settings in that the Geolocation API now needs to be hosted from a secured HTTPS domain.

It appears that the Ionic environment is not served over a HTTPs domain since I get the error:

Only secure origins are allowed

Whenever I try to access the API. This is through Ionic serve and Ionic run android.

So my question is what do I do now? How do I get my application on a secured domain? Or if there is no hope is there an alternative?

Any help is appreciated.


Leaflet JS is a great alternative to Google Maps with most of the functionality through the plugins.

The article also says:

localhost has been declared as "potentially secure" in the spec and in our case geolocation requests served at the top level over localhost will still work.

Ionic serve uses localhost.

Yeah thats what I thought too but I’m still getting the error even in ionic serve: Nonetheless I wouldn’t want to use something that I know would only work on localhost.

I will check out leafletJS but would it not be better to move my app to a secure location? Getting someones location really is a security concern.

I’m guessing it will work once on a device but for development try the ionic serve url in Firefox or any browser other than Chrome.

The app I’m developing has a geolocation component but I haven’t got to that stage yet. I’ll check back when I know more.

btw Geolocation conerns when releasing app