I am attempting to draw a simple box polygon that overlaps the international dateline. Currently when creating the polygon it wraps in the opposite direction.
Full example : 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);I'm not sure if there is a config setting that I missed in the OpenLayers 3 API or a conversion that must be made on the data points. Any guidance would be most appreciated.
أكثر...
Full example : 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);I'm not sure if there is a config setting that I missed in the OpenLayers 3 API or a conversion that must be made on the data points. Any guidance would be most appreciated.
أكثر...