點樣加一個google map driving direction 係website ?



呢個係一個客原來html website.
html website就好簡單,只要用貼google map embedded code 就得

但點樣用api 來gen一個咁嘅map 呢?
  1. <script>
  2.   function initialize() {
  3.     var position = new google.maps.LatLng(<?php echo $page->Map->lat;?>, <?php echo $page->Map->lng;?>);
  4.     var mapCanvas = document.getElementById('map-canvas');
  5.     var mapOptions = {
  6.       center: position,
  7.       zoom: 18,
  8.       panControl: false,
  9.       zoomControl: true,
  10.           mapTypeControl: false,
  11.       zoomControlOptions: {
  12.           style: google.maps.ZoomControlStyle.SMALL
  13.       },
  14.       mapTypeId: google.maps.MapTypeId.ROADMAP
  15.     }
  16.     var map = new google.maps.Map(mapCanvas, mapOptions);
  17.    
  18.     var marker = new google.maps.Marker  ({
  19.         position: position,
  20.         map: map,
  21.         title: "this is the place."
  22.     });        
  23.   }   
  24.   google.maps.event.addDomListener(window, 'load', initialize);

  25. </script>
複製代碼
上面嘅code 只產生一個map marker 的gmap
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

GMap.js is a good choice

TOP