0

This is my website for test: http://www.cv.nctu.edu.tw/shapefile-js-openlayers/ol_simple.html

My dem data is (.jpg).

var inProj = new OpenLayers.Projection('EPSG:3826');
var outProj = map.getProjectionObject();
var options = {   
    opacity: 1.0, 
    isBaseLayer: false,
    numZoomLevels: 20 
};

var extent = new OpenLayers.Bounds(16120,2409591,484824,2814500).transform(inProj,outProj);

var imageLayer = new OpenLayers.Layer.Image('Image Layer',  
    'http://www.cv.nctu.edu.tw/shapefile-js-openlayers/naturalearthdata/cultural/dem.jpg', 
    extent,
    new OpenLayers.Size(1,1),
    options);
map.addLayers([osm, GridshpLayer,BounderyshpLayer,RivershpLayer,SeashpLayer,imageLayer]);

error: enter image description here

  • Hi, have you tried googling it? Since you are using an old version of OpenLayers: check out gis.stackexchange.com/questions/26430/… – Tim.Lucas Feb 2 '15 at 8:05
  • Notice also that OpenLayers.Layer.Image most probably does not support .img format directly but you must convert it to jpg, png or somethign else. List of supported formats is unclear gis.stackexchange.com/questions/110291/…. – user30184 Feb 2 '15 at 9:26
  • OK thanks. I already tried it. But I used wrong keyword and couldn't find. I will try more keyword. Thanks a lot. – Seventysecond Feb 2 '15 at 10:30
0

Your problem is completely unrelated to your question's title.

The JS interpreter doesn't even reach the line where you add the image layer because of an earlier "Uncaught TypeError: Cannot read property 'proj' of null" exception in the following line:

var extent = new OpenLayers.Bounds(16120,2409591,484824,2814500).transform(inProj,outProj)

This is because outProj is null - apparently map is not yet initialized fully so map.getProjectionObject(); returns null. You can test this by removing the reprojection:

var extent = new OpenLayers.Bounds(16120,2409591,484824,2814500);

Even though the page clearly still doesn't work correctly, you won't get fatal JS exceptions and you'll see the map rendered.

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.