首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

GIS学习记录(五):OpenLayers显示Googlemap

2012-08-07 
GIS学习记录(五):OpenLayers显示Google地图使用Google api v2版本需要域名对应的key, v3版本api可以直接使

GIS学习记录(五):OpenLayers显示Google地图

使用Google api v2版本需要域名对应的key, v3版本api可以直接使用

?

<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>

?

?

例子:

?

<!DOCTYPE html><html><head><title>Google</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><link rel="stylesheet" href="css/style.css" type="text/css" /><link rel="stylesheet" href="css/pageStyle.css" type="text/css" /><script type="text/javascript" src="js/OpenLayers/lib/OpenLayers.js"></script><script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script><script type="text/javascript">var map, layer_street;function init() {// Creating the Map Viewermap = new OpenLayers.Map("map",{maxResolution:'auto',maxExtent: new OpenLayers.Bounds(        -128 * 156543.03390625,        -128 * 156543.03390625,        128 * 156543.03390625,        128 * 156543.03390625    ),    displayProjection: new OpenLayers.Projection("EPSG:4326")});layer_street = new OpenLayers.Layer.Google(    "Google Streets", // the default    {    numZoomLevels: 20 ,    projection: "EPSG:900913",    });map.addLayer(layer_street);map.zoomToMaxExtent();map.setCenter(new OpenLayers.LonLat(12945347.18614,4859501.42103), 13);map.addControl(new OpenLayers.Control.LayerSwitcher());map.addControl(new OpenLayers.Control.MousePosition());}</script></head><body onload="init()"><div id="map" name="code">@CHARSET "UTF-8";body {margin: 0;padding: 0;height: 100%;}.bigmap {position: absolute;left: 0;top: 0px;padding: 0;width: 100%;height: 100%;border: 1px solid #333;}
?

参考:

Google (v3) Layer Example http://www.openlayers.org/dev/examples/google-v3.html

?

热点排行