Using Google’s example code for detecting a user’s location, I setup a basic page that detects a user’s location on a map. I also setup a separate page that drops a marker on a map at a specific coordinate. I want to combine these functions into one script. That is, I want to drop a marker on the map at the location detected, but I can’t seem to get it to work. My code detects the user’s location, but doesn’t drop a marker. I’m sure it’s something simple, but I’m not familiar with Javascript, so I’m having trouble resolving the problem.
Below is Google’s example code. What would I need to add to display the marker at initialLocation? I tried adding the following code:
var marker = new google.maps.Marker({
position: initialLocation,
map: map,
title: "You are here"
});

Try calling
setMap()after you’ve created the marker: