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]


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.

  • Please look at this plunker. I don't see the need of a new ol.proj.Projection object. Jun 3 '15 at 12:17
  • I think you can/should simplify this a little bit. Jun 3 '15 at 12:18
  • Without projection I have no image: pastebin.com/2DRdvWdd My imgExtent is the array of my Bounds from ol2: [44823.715846278064, 66102.38217556383, 49823.715846278064, 71102.38217556383]
    – Olivier
    Jun 3 '15 at 15:07
  • Oh sorry, my comment was precipitate. Your code looks like this example Jun 4 '15 at 9:59
  • Exactly I used this one. Except I need to keep the original extent and not use a local one. in OL2 I didn't have to specify an extent for map, it used just a MaxExtent and the center calculated from the Bounds. But I cannot use a StaticImage with this extent: [44823, 66102, 49823, 71102] in a window of [0, 0, 500, 500] and I cannot use the a Map view with this extent neither.
    – Olivier
    Jun 4 '15 at 11:56

Had the same problem and finally found the answer (not sure where). Here's what worked for me:

var ovProj = ol.proj.get('EPSG:3857');
source: new ol.source.ImageStatic({
        url: "images/MAP/DYNAMIC/T_1.png",
        imageSize: [1239,748],
        imageExtent: [-14483048.340, 2291674.487,-6775420.041, 6947393.399],
        projection: ovProj 

The examples in OL3 aren't expecting one to use a geo-referenced static image in the view for the map, though one could do this in OL2 previously. So, for OL3, you have to specify the map projection of the image differently than one had to before in the layer declaration. Looks like you would use the max values in your extent for the imageSize. Hope this is what you were looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.