niiyz
5/22/2015 - 8:21 AM

GoogleMapでWebサービスを作る説明ソース2。

GoogleMapでWebサービスを作る説明ソース2。

<!DOCTYPE html>
<html>
<head lang="ja">
<meta charset="UTF-8">
<style>
#myMap {
  width: 500px;
  height: 500px;
}
</style>
</head>
<body>
<div id="myMap"></div>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
  var latLng = new google.maps.LatLng(36.861751, 136.991468);
  var mapOptions = {
    zoom: 10,
    center: latLng
  };
  var div = document.getElementById("myMap");
  var map = new google.maps.Map(div, mapOptions);
  // マップイベント
  google.maps.event.addListener(map, 'click', function(event) {
    var position = event.latLng;
    var marker = new google.maps.Marker({
      position: position,
      map: map
    }); 
  });
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>