JS调用goole地图,调用了http://ditu.google.com/maps/api/js?sensor=true,源码如下:

<!--调用谷歌地图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       
}            
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>
 
JS调用google地图,增加了所在位置的功能。
调用了http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=jshttp://ditu.google.com/maps/api/js?sensor=true,源码如下:
<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 on 2013-02-01 16:42  chinaagan  阅读(846)  评论(0编辑  收藏  举报