Applying geolocation in phonegap doesn't work

Hi,

I’m rather new to this and currently working on my first app (for a school project). I followed this https://www.w3.org/TR/geolocation-API/ tutorial. When I open the project in the browser (on a pc) it gives the coordinates but once installed (though phonegap) on my phone nothing seems to happen. Also the implementation with google maps does not seem to work (also not on the pc). Can any of you help me or redirect me to easy to follow guids?

This is the code I have so far:

<p>Click the button to get your coordinates.</p>

				<button onclick="getLocation()">Try It</button>

				<p id="demo"></p>

				<script>
				var x = document.getElementById("demo");

				function getLocation() {
				  if (navigator.geolocation) {
					navigator.geolocation.getCurrentPosition(showPosition);
				  } else {
					x.innerHTML = "Geolocation is not supported by this browser.";
				  }
				}

				function showPosition(position) {
				  x.innerHTML = "Latitude: " + position.coords.latitude +
				  "
Longitude: " + position.coords.longitude;
				}
				</script>

These are the sources I looked at as well:

https://demos.jquerymobile.com/1.4.5/map-geolocation/

https://www.w3.org/TR/geolocation-API/

https://forum.jquery.com/topic/jquery-mobile-activating-geolocation-on-mobile-devices

https://mobiforge.com/design-development/html5-mobile-web-a-guide-geolocation-api

https://cordova.apache.org/docs/en/3.0.0/cordova/geolocation/geolocation.getCurrentPosition.html

https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API

Thank you in advance for your help.