簡體   English   中英

Google地圖會在點擊標記時指定一個php彈出窗口

[英]Google Maps assign a php pop-up window on clicking a marker

假設我在地圖上的特定位置放置了一個標記。 我希望程序在用戶單擊此標記時打開一個名為bla.php的彈出窗口。

這是我已經完成的標記:

<!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: 0; padding: 0 }
  #map-canvas { height: 100% }
</style>
<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDxVucBtLP4XefoM4syoigBgXntwkVGxv8&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
  var mapOptions = {
zoom: 4,
center: new google.maps.LatLng(48, 2),
mapTypeId: google.maps.MapTypeId.ROADMAP
  };

 var map = new google.maps.Map(document.getElementById('map-canvas'),
  mapOptions);

var position = new google.maps.LatLng(48,2);

var marker = new google.maps.Marker({
  position: position,
  map: map
});

marker.setTitle("pv-unit");  
}

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


 </script>
  </head>
  <body>
    <div id="map-canvas"/>
  </body>

我試了一下,整個地圖都沒有加載

首先,您需要一個標記的事件監聽器。 然后在其中,無論你想要打開彈出窗口的代碼,例如

google.maps.event.addListener(marker, 'click', function() {
    window.open('blah.php','name','height=200,width=150');
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM