0

I'm using php and I want to fetch two columns from table like Latitude and Longitutde and add the markers on google map based on lat and long values, how i do..

1 Answers1

-1

After you get latitude and longitude data,

<div id="map"></div>
<script>

  function initMap() {
    var myLatLng = {lat: <?php echo $lat; ?>, lng: <?php echo $lng; ?>};

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 4,
      center: myLatLng
    });

    var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      title: 'Hello World!'
    });
  }
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>

API Key must be included

Оzgur
  • 432
  • 2
  • 10