I'm a beginner when it comes to working with Google Maps and JavaScript. My goal is to interact with the map using external links or lists.
One issue I am facing is the inability to select markers on the map by their id.
I don't want to have to store all markers in a list or array and iterate through them because I don't know how many there will be at any given time.
All I want is to be able to select markers by their unique ids so that I can manipulate them, like opening info windows or removing them.
In my `changeIcon()` function, I've attempted different methods but none have been successful so far.
<html>
....
<div id="mapview"></div>
<a class="test-link" onmouseover="changeIcon()">Link</a>
<script>
function changeIcon()
{
//marker = map.selectMarker("4");
//marker = markers[4];
//infowindow.open(map,marker);
//$("#mapview").map.removeMarker(4);
}
var map = new google.maps.Map(document.getElementById('mapview'),
{
center: {lat: 44.540, lng: -78.546},
zoom: 16
});
function initMap()
{
var marker = new google.maps.Marker({
position: userPosition,
map: map,
id: 4
});
}
</script>
</html>
............................................