首页 > 代码库 > openLayers加载高德地图
openLayers加载高德地图
之前用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: getXYZ21 * 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 },
openLayers加载高德地图
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。