java调用百度地图和谷歌地图

java调用百度地图: 
示例代码如下(baidu.jsp): 
Java代码   收藏代码
  1. <%@ page contentType="text/html; charset=gb2312"%>  
  2. <!DOCTYPE html>  
  3. <html>  
  4.     <head>  
  5.         <title>百度地图javascript</title>  
  6.         <script type="text/javascript">  
  7. function initialize() {  
  8.     var mp = new BMap.Map('map');  
  9.     mp.centerAndZoom(new BMap.Point(121.213431.0576), 15);  
  10. }  
  11.   
  12. function loadScript() {  
  13.     var script = document.createElement("script");  
  14.     script.src = "http://api.map.baidu.com/api?v=1.4&callback=initialize";  
  15.     document.body.appendChild(script);  
  16. }  
  17.   
  18. window.onload = loadScript;  
  19. </script>  
  20.     </head>  
  21.     <body>  
  22.         <div id="map" style="width: 1500px; height: 1000px"></div>  
  23.     </body>  
  24. </html>  

效果显示: 
[img] 

[/img] 

java调用google地图: 
实例代码如下(google.jsp): 
Java代码   收藏代码
  1. <%@ page contentType="text/html; charset=gb2312"%>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml"  
  4.     xmlns:v="urn:schemas-microsoft-com:vml">  
  5.     <head>  
  6.         <meta http-equiv="content-type" content="text/html; charset=gb2312" />  
  7.         <title>谷歌地图javascript</title>  
  8.         <script  
  9.             src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAmZzPqf2aW-7Si6ot-HY9-hRhm3yhlCBaxy4FA8xZJReMAoDMwhQtB3B5zaWqCOSd_tjuCOoj9SsVZw"  
  10.             type="text/javascript">  
  11. </script>  
  12.         <script type="text/javascript">  
  13. function initialize() {  
  14.     if (GBrowserIsCompatible()) {  
  15.         var map = new GMap2(document.getElementById("map_canvas"));  
  16.         map.setCenter(new GLatLng(31.0576121.2134), 14);  
  17.     }  
  18. }  
  19. </script>  
  20.     </head>  
  21.     <body οnlοad="initialize()" οnunlοad="GUnload()" >  
  22.         <div id="map_canvas" style="width: 1500px; height: 1000px">  
  23.         </div>  
  24.     </body>  
  25. </html>  

效果显示: 
[img] 

[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值