Blame view

map.php 672 Bytes
dbaadcdd8   Tom Huang   Signed-off-by: To...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  <?php
  print_r(getLatLng('台灣新北市'));
  function getLatLng($address){
   
      // url encode the address
      $address = urlencode($address);
       
      // google map geocode api url
      $url = "http://maps.google.com/maps/api/geocode/json?address={$address}";	
      $curl = curl_init() ;
      curl_setopt($curl , 
              CURLOPT_URL , 
              "$url") ;
       
      curl_setopt($curl , CURLOPT_RETURNTRANSFER , 1) ;
           
      $info = curl_exec($curl) ;
   
      curl_close($curl) ;
  	
  	$a = json_decode($info);
  	
  	$latlng = array($a->results['0']->geometry->bounds->southwest->lat,$a->results['0']->geometry->bounds->southwest->lng);
  	
  	return $latlng;
      
  }
c75c321b1   Tom Huang   a
28
29
  ?>
  aaa