Google map 埋め込み php

<div id="map" style="width:100%; height:400px"></div>
<?php
$gallery->name = '店名';
$gallery->lat = 35;
$gallery->lang = 139;
?>
<script>
function initMap() {
var myLatLng = {lat: <?= $gallery->lat ?>, lng: <?= $gallery->lang ?>};

// Create a map object and specify the DOM element for display.
var map = new google.maps.Map(document.getElementById('map'), {
  center: myLatLng,
  scrollwheel: false,
  zoom: 15
});

// Create a marker and set its position.
var marker = new google.maps.Marker({
  map: map,
  position: myLatLng,
  title: '<?= $gallery->name ?>'
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=APIキー&callback=initMap" async defer></script>

PAGE TOP