我使用的是来自标尺加件 2的OpenLayers,它没有测地选项。
我知道标度线有一个测地线选项,但是考虑到标度栏有更多的选项,在这个选项中引入测地线选项是很好的。
有人能帮我吗?如何在标度栏中引入测地线选项?
谢谢
发布于 2014-09-05 00:54:00
我想我解决了。
首先,我添加了一个测地线选项,这样用户就可以选择是否需要测地测量。
其次,我创建了这个函数(基于ScaleLine):
getGeodesicRatio: function() {
var res = this.map.getResolution();
if (!res) {
return;
}
var curMapUnits = this.map.getUnits();
var inches = OpenLayers.INCHES_PER_UNIT;
// convert maxWidth to map units
var maxSizeData = this.maxWidth * res * inches[curMapUnits];
var geodesicRatio = 1;
if(this.geodesic) {
var maxSizeGeodesic = (this.map.getGeodesicPixelSize().w ||
0.000001) * this.maxWidth;
var maxSizeKilometers = maxSizeData / inches["km"];
geodesicRatio = maxSizeGeodesic / maxSizeKilometers;
}
return geodesicRatio;
},
第三,我在其他函数中插入了测地线比率:
"getComp"
var ppdu = OpenLayers.DOTS_PER_INCH * system.inches[unitIndex]
/ this.getGeodesicRatio() / this.scale;
"setSubPros"
var ppdu = OpenLayers.DOTS_PER_INCH * system.inches[unitIndex]
/ this.getGeodesicRatio() / this.scale;
我希望这是有用的。
https://stackoverflow.com/questions/25656288
复制相似问题