Geolocation is a vast API, which is why it was incorporated into the browser as a separate object, rather than with all the other APIs. Other than using getCurrentPosition(), you can use watchPosition(callback) to specify a function to call when the position changes (useful for laptops and devices)
See the below links for learning about more Google Maps:
To use Geolocation:
if ("geolocation" in navigation) {//to detect whether geolocation is supported
navigator.geolocation.getCurrentPosition(function(position){
latitude = position.coords.latitude;//gets latitude
longitude = position.coords.longitude;//gets longitude
});//gets position once
navigator.geolocation.watchPosition(function(position){
latitude = position.coords.latitude;//gets latitude
longitude = position.coords.longitude;//gets longitude
});//gets position when it changes
}
Good job for finishing Part Two.
I hope it wasn't too easy for you.
If you're a beginner, you might have to meditate on Parts One and Two.
Part Three is definitely difficult. But I didn't make it impossible for beginners.
Part Three could have been made impossible for beginners. But it's not. Why?
I didn't give you all of the information sidebars after you finished challenges for nothing.
All that information was for you to learn (even for beginners).
I'm testing you on that in Parts 3 and 4. Don't say I didn't warn you.
And now I'm telling you this one more time.
The console is your best friend in these challenges. And remember to go back to the information I gave you.