I need this to be an external JavaScript that links to an HTML5 document: A butt
ID: 3591456 • Letter: I
Question
I need this to be an external JavaScript that links to an HTML5 document:
A button to map the Current Location of the user
A Locations dropdown list (select)
A Mapped location description, latitude, and longitude span
A Map div element
A button to center the image on the map
A Link to the Google Maps JavaScript API
I need to use ES6 syntax: let and const rather than var (replacing functions with arrow functions is optional)
An event handler mapped to a function to find current location using button click event, a function to map selected location using select change event, and a function to center map using click event
I also need a global locations array and a global map object with properties map, marker, and latLong to hold the current map Google map object information
I don't know how to populate the locations array with at least three objects with properties description, latitude, and longitude (hint: use Google Maps to search for a location, then click on the location's marker select "What's here?" to get the location's latitude and longitude)
I need to populate the dropdown from the locations array objects using createElement and appendChild
I also need a handle window.onload event
I don't know how to use addEventListener method for all other event handlers
I need to be able to use the HTML5 geolocation to get the user's current location (latitude and longitude)
I don't know how to detect if the user's browser does not support HTML5 geolocation and provide a warning
I need be able to Map current location function, map a location from a dropdown list, display a mapped location marker, and to re-center the map to the mapped location marker
I can't use any inline Javascript of CSS
Explanation / Answer
Find your ans here:
<!DOCTYPE html>
<html>
<body>
<p>Click the here to acess yourlocation.</p>
<button>Your Location</button>
<p id="test"></p>
<script>
var x = document.getElementById("test");
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 +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
From this code you can get your current location then you can get each and every thing taht you want.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.