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

java调用百度地图:
示例代码如下(baidu.jsp):

<%@ page contentType="text/html; charset=gb2312"%>
<!DOCTYPE html>
<html>
<head>
<title>百度地图javascript</title>
<script type="text/javascript">
function initialize() {
var mp = new BMap.Map('map');
mp.centerAndZoom(new BMap.Point(121.2134, 31.0576), 15);
}

function loadScript() {
var script = document.createElement("script");
script.src = "http://api.map.baidu.com/api?v=1.4&callback=initialize";
document.body.appendChild(script);
}

window.onload = loadScript;
</script>
</head>
<body>
<div id="map" style="width: 1500px; height: 1000px"></div>
</body>
</html>

效果显示:
[img]
[img]http://dl.iteye.com/upload/attachment/0082/9377/842fc626-6678-3f0d-965c-07e3f12397b0.jpg[/img]
[/img]

java调用google地图:
实例代码如下(google.jsp):

<%@ page contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>谷歌地图javascript</title>
<script
src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAmZzPqf2aW-7Si6ot-HY9-hRhm3yhlCBaxy4FA8xZJReMAoDMwhQtB3B5zaWqCOSd_tjuCOoj9SsVZw"
type="text/javascript">
</script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(31.0576, 121.2134), 14);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()" >
<div id="map_canvas" style="width: 1500px; height: 1000px">
</div>
</body>
</html>


效果显示:
[img]
[img]http://dl.iteye.com/upload/attachment/0082/9382/28306e8c-6cf4-3d57-add9-7a0ad9729d43.jpg[/img]
[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值