------ 文章開始 ------


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0px; padding: 0px }
  #map_canvas { height: 100% }
</style>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false">;
</script>

<script type="text/javascript">

var map;
var touchMapWindow;
var nowLatlng;

function initialize(){
    var centerLatlng = new google.maps.LatLng(25.03, 121.3);
    var myOptions = {
      zoom: 10,
      center: centerLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
         myOptions);

var windowContent = '<button type="button" onclick="placeMarker(nowLatlng,map)">Add andress here!</button>';
touchMapWindow = new google.maps.InfoWindow({ content: windowContent, 
  maxWidth: 100});

    google.maps.event.addListener(map, 'click', function(e) {
         placeInfoWindow(e.latLng, map);
    });
}

function placeInfoWindow( position, map){
nowLatlng = position;
map.setCenter(position);
touchMapWindow.setPosition(position);
touchMapWindow.open(map);
}

function placeMarker( position, map){
var marker = new google.maps.Marker({
position: position,
map: map
});
map.panTo(position);
google.maps.event.addListener( marker, 'click', function(){
marker.setMap(null);
});
touchMapWindow.open(null);
}

</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:800px; height:500px">
  </div>
</body>
</html>
------ 文章結尾 ------

[複製網址] [開新視窗] [檢舉短網址] [QR條碼]

服務條款 - 加入會員(免費) - 回報問題網址 - 聯絡偶們 -

© 2026 PPT.cc