阅读:3420回复:0
openlayers加载本地 google map的例子
<P>openlayers加载本地 google map的例子</P>
<P> function get_img_url(bounds)<BR> {<BR> var res = this.map.getResolution();<BR> var bbox = this.map.getMaxExtent();<BR> var size = this.tileSize<BR> <BR> var z = this.map.getZoom();<BR> var x = Math.round ((bounds.left - bbox.left) / (res * size.w));<BR> var y = Math.round ((bbox.top - bounds.bottom) / (res * size.h));<BR> <BR> var path;<BR> if(x<0 || y<0)<BR> path = "noMap.png";<BR> else<BR> path = "map/gm_"+x+"_"+y+"_"+z+".png";</P> <P> var url = this.url;<BR> return url + path;<BR> }</P> <P> function init()<BR> {<BR> var options = {<BR> controls: [new OpenLayers.Control.MouseDefaults(),<BR> new OpenLayers.Control.MousePosition({element:$('position')}),<BR> new OpenLayers.Control.Scale($('scale'))],<BR> numZoomLevels:13<BR> };<BR> map = new OpenLayers.Map('map', options);<BR> var myMap = new OpenLayers.Layer.TMS("myMap TMS","Images/",{type:'png', getURL:get_img_url });<BR> map.addLayer( myMap );<BR> var point = new OpenLayers.LonLat(lon, lat);<BR> map.setCenter ( point , 10 ); </P> <P>纬度对应不起来, 求解</P> |
|