发布网友 发布时间:2022-03-03 23:53
共1个回答
热心网友 时间:2022-03-04 01:22
用javascript编程,调用google map api实现的
这是在你的页面嵌入google map的方法:
1,首先,你要申请一个google map api key,并将一段代码包含到你的叫阿vascript代码中,这样你才可以调用google map api;
2,在你的页面中给出一个google map的canvas,在HTML页中用<DIV>标签指定;
3,创建google map 对象,并指定地图类型,比例尺,中心点之类的参数;
以下是为每个标注都需要做的:
1,给出经纬坐标点(可以通过地址向google查询);
2,用此坐标创建一个标注(属于layout类的marker),google会自动放置这个标准在标定的坐标点;
详细请查询GOOGLE API文档:http://code.google.com/apis/maps/
==============这是个放置marker的例子=======================
把以下内容拷贝到一个文本文档,并存为"test.html",用浏览器打开便可看到随机放置了一些marker的google map
============================================
<!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=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Markers</title>
<script src="http://maps.google.com/maps?file=api&;v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(latlng));
}
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
============================================================
更多的例子:http://code.google.com/apis/maps/documentation/examples/index.html