Tuesday, 11 April 2023

How to position viewport to top center marker google maps

I am new to google maps and following is code snippet of google maps The marker is in middle of the screen but how can I appear at top center (top middle as illustrated in image) of the screen.

function initMap() {
  const myLatLng = { lat: -25.363, lng: 131.044 };
  const map = new google.maps.Map(document.getElementById("map"), {
    zoom: 4,
    center: myLatLng,
  });

  new google.maps.Marker({
    position: myLatLng,
    map,
    title: "Hello World!",
  });
}

window.initMap = initMap;

enter image description here



from How to position viewport to top center marker google maps

No comments:

Post a Comment