之前用openlayers对高德,百度,腾讯,bing,supermap,天地图,arcgis,google等地图进行了对接,今天简单介绍一下openlayers+高德:
在Openlayers.Layer.XYZ.js中有如下更改:(百度兴趣点下载工具:http://www.cnblogs.com/songjiang6940/p/baiduPOI.html)
1 * bounds - {<OpenLayers.Bounds>} 2 * 3 * Returns: 4 * {String} A string with the layer‘s url and parameters and also the 5 * passed-in bounds and appropriate tile size specified as 6 * parameters 7 */ 8 getURL: function (bounds) { 9 var xyz = this.getXYZ(bounds); 10 var url = this.url; 11 if (OpenLayers.Util.isArray(url)) { 12 var s = ‘‘ + xyz.x + xyz.y + xyz.z; 13 url = this.selectUrl(s, url); 14 } 15 16 return OpenLayers.String.format(url, xyz); 17 }, 18 19 /** 20 * Method: getXYZ 21 * Calculates x, y and z for the given bounds. 22 * 23 * Parameters: 24 * bounds - {<OpenLayers.Bounds>} 25 * 26 * Returns: 27 * {Object} - an object with x, y and z properties. 28 */ 29 getXYZ: function(bounds) { 30 var res = this.getServerResolution(); 31 var x = Math.round((bounds.left - this.maxExtent.left) / 32 (res * this.tileSize.w)); 33 var y = Math.round((this.maxExtent.top - bounds.top) / 34 (res * this.tileSize.h)); 35 var z = this.getServerZoom(); 36 37 if (this.wrapDateLine) { 38 var limit = Math.pow(2, z); 39 x = ((x % limit) + limit) % limit; 40 } 41 42 return {‘x‘: x, ‘y‘: y, ‘z‘: z}; 43 },
时间: 2024-10-05 04:59:11