How to connect geolocation with google maps?

tips: Get google maps api and input the latitude and longitude that have been obtained right.

Info
Warning alert!, Not all devices or browsers are fully supported.

The following is an example of the program code

<!-- Google Map Api -->

<iframe
  id="sodik-gmap-canvas"
  width="100%"
  height="300px"
  frameborder="0"
  scrolling="no"
  marginheight="0"
  marginwidth="0"
></iframe>

<script>
  // navigator.geolocation

  var iframeGoogle = document.getElementById("sodik-gmap-canvas"),
    getLocation = () => {
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(getPosition);
        // The Geolocation.getCurrentPosition() method is used to get the current position of the device.
      } else {
        // Section showing error or incompatible browser.
      }
    },
    getPosition = (position) => {
      iframeGoogle.setAttribute(
        "src",
        "https://maps.google.com/maps?width=100%25&height=250&hl=en&q=" +
          position.coords.latitude +
          "," +
          position.coords.longitude +
          "+(Instagram%20@project_sodik)&t=&z=14&ie=UTF8&iwloc=B&output=embed"
      );
    };
  getLocation();

  // [open-source] : location:github.com/tamddk/library/tree/main/getGeoLocationWithGMAPS
</script>