js调用谷歌地图

<script language="javascript" type="text/javascript"

src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>

<!--调用谷歌地图js,zoom缩放倍数,center中心,mapTypeId地图类型-->    
<script type="text/javascript" src="http://ditu.google.com/maps/api/js?sensor=true"></script>    
<script language="javascript">    
 var geocoder;    
  var map;    
  function initialize() {    
    geocoder = new google.maps.Geocoder();    
    var latlng = new google.maps.LatLng(39.9493, 116.3975);    
    var myOptions = {    
      zoom: 15,    
      center: latlng,    
      mapTypeId: google.maps.MapTypeId.ROADMAP    
    }    
    var address = remote_ip_info.country+remote_ip_info.province+remote_ip_info.city; 
 document.getElementById('add').innerHTML = "欢迎来自:"+address+"的朋友!";
   var img='http://avatar.csdn.net/B/9/A/1_youacai.jpg';  
 
    if (geocoder) {    
      geocoder.geocode( { 'address': address}, function(results, status) {    
        if (status == google.maps.GeocoderStatus.OK) {   
          map.setCenter(results[0].geometry.location);    
          var marker = new google.maps.Marker({    
              map: map,     
              position: results[0].geometry.location,    
               title:'位置',  
               icon:img  
        
          });   
   
        }     
      });    
    }    
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);    
  }   
     
  
    
  </script>   

<body onload="initialize()">  
 <div id="add"  style=" height:26px;color:#F00;font-size: 18pt;"></div>
 
 <div id="map_canvas" style="width: 580px; height: 480px;"></div>

posted @ 2013-03-13 14:54  Hello!园子  阅读(383)  评论(0编辑  收藏  举报