Applying geolocation in phonegap doesn't work


I’m rather new to this and currently working on my first app (for a school project). I followed this 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>

				var x = document.getElementById("demo");

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

				function showPosition(position) {
				  x.innerHTML = "Latitude: " + position.coords.latitude +
Longitude: " + position.coords.longitude;

These are the sources I looked at as well:

Thank you in advance for your help.