Saturday, 11 March 2017

javascript - OpenLayers 3 how to keep original image extent


I'm new at ol3, I'm trying to display my GIS view by updating my ol2 code.


I created the projection and I can display my static image but I'm obliged to use local extent [0, 0, 1024, 968] instead of my image extent [44823.715846278064, 66102.38217556383, 49823.715846278064, 71102.38217556383] otherwise I get a blank screen. In ol2 I made my bounds with the original datas and everything worked fine :/



here the new code :


    var extent = [0, 0, 1024, 968];
var projection = new ol.proj.Projection({
units: 'pixels',
extent: extent
});

MAP = new ol.Map({
target: target,
view: new ol.View({

projection: projection,
center: ol.extent.getCenter(extent),
zoom: 2
})
);

var imageProjection = new ol.proj.Projection({
units: 'pixels',
extent: [0, 0, 1024, 968]
});


var graphic = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: layerData,
projection: imageProjection,
imageExtent: [0, 0, 1024, 968]
})
});

MAP.addLayer(graphic);


I need to keep the original extent to communicate with my server to generate the good image when moveend happens. I tried to use an EPSG:4326 projection but it doesn't work. I'm missing something but I don't know where.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...