来自OpenLayers 2.x的OpenLayers.Bounds的概念是否仍然存在于OpenLayers 3中?它有什么变化,它的新名称是什么?界限如何在OpenLayers 3中工作?
回答
UPDATE:OL4:https://openlayers.org/en/latest/apidoc/ol.html#.Extent
看来,对于 '界限' 或 '边框'(BBOX)这个新词是 '程度'。 见:
- http://openlayers.org/en/v3.20.1/apidoc/ol.extent.html
- http://openlayers.org/en/v3.20.1/apidoc/ol.View.html#fitExtent
- http://openlayers.org/en/v3.20.1/apidoc/ol.source.Vector.html#getExtent
的一种方法,找出事物的时刻是在OL3回购运行搜索,例如: https://github.com/openlayers/ol3/search?p=3&q=BBOX&type=Code
我可以给你一些代表这些问题:),那个新标签将被证明是相当有用的,因为OL3与OL3不兼容,因为现在必须使用两者,否则没有人会看到这些问题。 –
我的意思是'因为OL3与OL2不兼容' –
只是为答案增加一个小例子: 边界现在被称为“范围”,它不再是一个复杂的对象/类,而只是四个数字的数组。 “ol.extent”中有一些帮助函数用于转换等。
var tfn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
var textent = ol.extent.applyTransform([6, 43, 16, 50], tfn);
var textent = ol.proj.transformExtent([6, 43, 16, 50], 'EPSG:4326', 'EPSG:3857');
我无法找到一个API的文档中
http://ol3js.org/en/master/apidoc到目前为止您已经阅读:刚上如何来转换一个小例子
source获取信息。
API-Docs自BETA以来已经完成。所以你现在就可以找到它。
正如评论中所述,正确的API函数现在是ol.proj.transformExtent()。
Did'nt发现有关此功能的任何文档,但程度似乎工作:
var vectorSources = new ol.source.Vector();
var map = new ol.Map({
target: map_id,
layers: [
new ol.layer.Tile({
source: ol.source.OSM()
}),
new ol.layer.Vector({
source: vectorSources
})
],
view: new ol.View({
center: [0, 0],
zoom: 12
})
});
var feature1 = new ol.Feature({
geometry: new ol.geom.Point(coords)
});
vectorSources.addFeature(feature1);
var feature2 = new ol.Feature({
geometry: new ol.geom.Point(coords)
});
vectorSources.addFeature(feature2);
map.getView().fitExtent(vectorSources.getExtent(), map.getSize());
方法vectorSources.getExtent()
还可以通过任何程度对象来代替,就像这样:
map.getView()。fitExtent([1,43,8,45],map.getSize());
由于OpenLayer 3.9,该方法改变了:
map.getView().fit(vectorSources.getExtent(), map.getSize());
谢谢。这似乎是目前文档的**程度**:http://openlayers.org/en/v3.0.0/apidoc/ol.extent.html – colllin
论的OpenLayers 3.17。1和尝试不同的东西,我能够设定的范围有两种不同的方式后:
A)作为@Grmpfhmblmentioned,使用ol.proj.transformExtent
功能象下面这样:
var extent = ol.proj.transformExtent(
[-0.6860987, 50.9395474, -0.2833177, 50.7948214],
"EPSG:4326", "EPSG:3857"
);
map.getView().fit(extent, map.getSize());
B)有点不寻常,使用ol.geom.Polygon
像这样:
// EPSG:3857 is optional as it is the default value
var a = ol.proj.fromLonLat([-0.6860987, 50.9395474], "EPSG:3857"),
b = ol.proj.fromLonLat([-0.2833177, 50.7948214], "EPSG:3857"),
extent = new ol.geom.Polygon([[a, b]]);
map.getView().fit(extent, map.getSize());
- 1. 如何使笔画不透明度在OpenLayers 3中工作3
- 2. Photoshop界限/作物如何工作JavaScript
- 3. Openlayers 3 forEachFeatureAtPixel无法正常工作点
- 4. Openlayers 3:Interaction DragBox不能正常工作
- 5. OpenLayers 3 fitExtent按预期工作
- 6. Openlayers限制缩放到整个世界
- 7. openlayers 3 - 单击多边形边界
- 8. 创建圈子后显示OpenLayers界限
- 9. 如何在OpenLayers中设置默认视图,而不限制边界?
- 10. Openlayers中的autoPanMargin在IE中不工作
- 11. 在OpenLayers 3中替换OpenLayers.Control.NavigationHistory 3
- 12. 在OpenLayers 3中使用Geowebcache瓷砖3
- 13. OpenLayers如何计算边界框坐标?
- 14. wmts作为底图在openlayers 3(basemap.at)
- 15. 如何通过OpenLayers 3中的地图边界绘制测地线?
- 16. Vector map()如何在actionscript 3中工作?
- 17. Freeradius 3中的sqlcounter/data限制如何工作?
- 18. ZoomToExtent OpenLayers 3
- 19. OpenLayers 3直线
- 20. Openlayers 3 Coords
- 21. TWebBrowser&OpenLayers 3
- 22. Openlayers 3文档
- 23. 的OpenLayers 3 interaction.draw()
- 24. OpenLayers,如何限制WMS图层范围
- 25. 如何让JQuery和Bootstrap 3在Google PageSpeed Insights世界中一起工作?
- 26. OpenLayers 3 - 几何集合空
- 27. 如何在OpenLayers 3中绘制多部分几何图形?
- 28. 如何在OpenLayers 3中获取当前中心图块?
- 29. 如何使用Proj4Js用的OpenLayers 3
- 30. 如何专门编译的OpenLayers 3
var mapExtent = map.getView()。calculateExtent(map.getSize()); – pstanton