mcr*_*eau 3 javascript openlayers-3
我试图绘制一个与国际日期线重叠的简单框多边形.目前,在创建多边形时,它会以相反的方向包裹.
完整示例:http://jsfiddle.net/mcroteau/dkk2yu3L/
期望的输出:
实际产量:
使用Javascript:
var wgs84Proj = new ol.proj.Projection({ code : "EPSG:4326" });
var origProj = new ol.proj.Projection({ code : "EPSG:900913" });
var mapTile = new ol.layer.Tile({
source: new ol.source.OSM()
});
var convertedCoordinates = [];
var unformattedCoordinates = [[175, 70], [175, 60], [-160, 60], [-160, 70]];
$(unformattedCoordinates).each(function(index, coordinate){
var lat = coordinate[0];
var lon = coordinate[1];
var circle = new ol.geom.Circle([lat, lon])
circle.transform(wgs84Proj, origProj);
convertedCoordinates.push(circle.getCenter());
});
var polygonGeometry = new ol.geom.Polygon([convertedCoordinates])
var polygonFeature = new ol.Feature({ geometry : polygonGeometry });
var vectorSource = new ol.source.Vector();
vectorSource.addFeature(polygonFeature);
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
var mapView = new ol.View({
center: [-19000000, 9500000],
zoom: 3
})
var map = new ol.Map({
layers : [mapTile],
target : 'map',
view : mapView
});
map.addLayer(vectorLayer);
Run Code Online (Sandbox Code Playgroud)
我不确定是否存在我在OpenLayers 3 API中遗漏的配置设置或必须在数据点上进行的转换.任何指导都将非常感激.
更新的工作示例
只需在X坐标上添加360度(或任何使用投影的总宽度),使它们位于右侧的世界中.更改[[175, 70], [175, 60], [-160, 60], [-160, 70]]到[[175, 70], [175, 60], [200, 60], [200, 70]].
OpenLayers使用投影坐标.[-160, 70]位于左侧/西侧[175, 70],因此点之间绘制的任何线都将向左移动(如您的示例所示).要使它向右/向东,你必须确保X坐标更高.
http://jsfiddle.net/dkk2yu3L/4/
| 归档时间: |
|
| 查看次数: |
2957 次 |
| 最近记录: |