APIによるGoogleMap

真ん中にマーカーが来ている


 <div class="map">

   <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
    <script>

      var mapZoom = 16;
      var mapCenter = new google.maps.LatLng(39.626028,140.1615576);緯度経度
      
      function mapCreate(){
        var mapOption={
          zoom:mapZoom,
          center:mapCenter
        };

      var map=new google.maps.Map(document.getElementById('map'),mapOption);
        markerCreate(map);
      }

      function markerCreate(map){
        new google.maps.Marker({
          position:mapCenter,
          map:map
        });

      }

      google.maps.event.addDomListener(window, 'load', mapCreate);

     </script>

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

 </div>

[css]これは必要

#map {
width: 50%;
height: 230px;
}

Categories:

,

Tags: