You have to add some settings to your config.xml file.
In the old days, geolocation in cordova apps was handled via a plugin. With HTML5, geolocation is now handled by the browser. But, because it’s available doesn’t mean you can access it. In order to access the users location data you have to ask for permission and this is kinda handled automatically.
Now, the geolocation plugin no longer handles any real geolocation services but it does handle the permission so you have to include it in your project and you have to tell the user why you want access to their location.
<plugin name="cordova-plugin-geolocation" spec="4.0.2">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="Tell the user why you want access to their location." />