php 調用goolge地圖代碼

來源:互聯網
上載者:User

<?php
 require('path.inc.php');
 header('content-Type: text/html; charset=utf-8');
 $borough_id = intval($_GET['id']);
 if(!$borough_id){
  echo '
  <script>
   parent.document.getElementById('mapDiv').style.display="none";
      parent.document.getElementById('mapDivLink').style.display="none";
    </script>
  ';
  exit;
 }
 $borough = new Borough($query);
 $boroughInfo = $borough->getInfo($borough_id,'*',1,true);
 //charsetIconv($boroughInfo,'gbk','utf-8');
 $pos = strpos($boroughInfo['borough_name'],'(');
 if($pos!==false){  
  $boroughInfo['borough_name'] = substr($boroughInfo['borough_name'],0,$pos);
 }
 
 $boroughInfo['borough_address'] = iconv('gb2312','utf-8',$boroughInfo['borough_address']);
 $boroughInfo['borough_name'] = iconv('gb2312','utf-8',$boroughInfo['borough_name']);
 
 $pos = strpos($boroughInfo['borough_name'],'(');
 if($pos!==false){  
  $boroughInfo['borough_name'] = substr($boroughInfo['borough_name'],0,$pos);
 }
 if(strpos($boroughInfo['borough_name'],'福州')===false){
  $boroughInfo['borough_name'] = "福州".$boroughInfo['borough_name'];
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>小區地圖</title>
    <script src="<?php echo $cfg['path']['js'].'jquery.js'; ?>" type="text/javascript"></script>
    <script src="http://ditu.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAHhTjWVGPsP7PRmx_R_91ZRTVyAFvJakBKxQFkhQ3JHiKjMJ6fhSBvkRl-6priBh_xdqXZcn6jaYGDw&hl=zh-CN" type="text/javascript"></script>
    <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>
   
    <script type="text/javascript">
    var map = null;
    var geocoder = null;
  document.domain="fangke.cc";
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        //map.setCenter(new GLatLng(39.917, 116.397), 13);
        geocoder = new GClientGeocoder();
        map.addControl(new GLargeMapControl());
          //map.addControl(new GMapTypeControl());
      }
    }

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
             parent.document.getElementById('mapDiv').style.display="none";
             parent.document.getElementById('mapDivLink').style.display="none";
            } else {
             $.post("ajax.php", { point: point,action:"point", id: "<?php echo $boroughInfo['id'];?>" } ,function(data){
               //alert(data);
              });
             
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address+"<br><span style='font-size:12px; color:#999; line-height:150%;'><?php echo $boroughInfo['borough_address']; ?></span><br><a href='<?php echo $cfg['url_community'];?>sale.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>二手房源:<?php echo $boroughInfo['sell_num']; ?>套</a><br><a href='<?php echo $cfg['url_community'];?>rent.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>出租房源:<?php echo $boroughInfo['rent_num']; ?>套</a>");
            }
          }
        );
      }
    }
    function setPoint(point){//php教程
   eval("var latlng = new GLatLng"+point+";");
   map.setCenter(latlng, 13);
   var marker = new GMarker(latlng);
   map.addOverlay(marker);
   marker.openInfoWindowHtml("<a href='<?php echo $cfg['url_community'];?>g-<?php echo $borough_id ?>.html' style='font-size:14px; color:#000; line-height:150%;' target='_blank'><?php echo $boroughInfo['borough_name']; ?></a><br><span style='font-size:12px; color:#999; line-height:150%;'><?php echo $boroughInfo['borough_address']; ?></span><br><a href='<?php echo $cfg['url_community'];?>sale.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>二手房源:<?php echo $boroughInfo['sell_num']; ?>套</a><br><a href='<?php echo $cfg['url_community'];?>rent.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>出租房源:<?php echo $boroughInfo['rent_num']; ?>套</a>");
    }
    </script>
  </head>

  <body onunload="GUnload()">
      <div id="map_canvas" style="width: 680px; height: 300px"></div>
  </body>
  <script type="text/javascript">
   initialize();
   <?php if ($boroughInfo['layout_map'] ){ ?>
     setPoint('<?php echo $boroughInfo['layout_map']; ?>');
    <?php }else{ ?>
     showAddress('<?php echo $boroughInfo['borough_name']; ?>');
    <?php } ?>
  </script>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.