java调用百度地图:
示例代码如下(baidu.jsp):
效果显示:
[img]
[img]http://dl.iteye.com/upload/attachment/0082/9377/842fc626-6678-3f0d-965c-07e3f12397b0.jpg[/img]
[/img]
java调用google地图:
实例代码如下(google.jsp):
效果显示:
[img]
[img]http://dl.iteye.com/upload/attachment/0082/9382/28306e8c-6cf4-3d57-add9-7a0ad9729d43.jpg[/img]
[/img]
示例代码如下(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]