如何调用google地图的一个简单示例

来源:互联网 发布:视频软件 编辑:程序博客网 时间:2024/06/08 02:33

首先至http://code.google.com/intl/zh-CN/apis/maps/signup.html注册得到使用地图的key

页面上使用代码:

<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>Google Maps JavaScript API Example</title>    <script src="http://maps.google.com/maps?file=api&v=2&sensor=true_or_false&key=你的Key" type="text/javascript"></script>    <script type="text/javascript">        function initialize() {            if (GBrowserIsCompatible()) {                var map = new GMap2(document.getElementById("map_canvas"));                map.setCenter(new GLatLng(39.9493, 116.3975), 13);            }        }    </script></head><body onload="initialize()" onunload="GUnload()">        <form id="form1" runat="server">      <div id="map_canvas" style="width: 500px; height: 300px"></div>    </form></body></html>


示例效果:



原创粉丝点击