I would like to add markers on google map with two locations, that are clickable. When I click on the button it should change the map marker with the location.
<script>
var map;
function initialize()
{
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(52.302516, 16.414546), //Setting Initial Position
zoom: 14,
});
var marker = new google.maps.Marker({
position: newLocation(),
map: map,
title: 'AGM-CORP',
icon: 'img/agm-marker.png'
});
}
function newLocation(newLat, newLng)
{
map.setCenter({
lat: newLat,
lng: newLng
});
}
google.maps.event.addDomListener(window, 'load', initialize);
$(document).ready(function ()
{
$("#1").on('click', function ()
{
newLocation(52.302516, 16.414546);
});
$("#2").on('click', function ()
{
newLocation(51.706478, 15.274753);
});
});
</script>
<div id="map-canvas"></div>
</div>
<h3>Zobacz lokalizację:</h3>
<button id="1" style="padding:10px; cursor:pointer;">Siedziba Firmy</button>
<button id="2" style="padding:10px;cursor:pointer;">Kopalnia Kruszyw</button>
</div>