3

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

I want to put my Shapefile in OpenLayers. I found an example at https://github.com/mattwigway/shapefile-js/tree/openlayers

I tried it and put my Shapefile in OpenLayers using proj4 to convert EPSG:3826 (my Shapefile's projection is EPSG:3826) to EPSG:4326.

But, I can't see my Shapefile on the OpenLayers map. What's wrong?

5

If you look at the picture below, you'll see your Shapefile is actually being displayed on the map. But it's not being projected to your map's reference system.

enter image description here

Your Shapefile has EPSG:4326 (as you can see here) and your map has EPSG:900913. So, in your ol_simple.js file, change line:

var outProj = new OpenLayers.Projection('EPSG:3857');

by:

var outProj = map.getProjectionObject();

And that should do the trick. Your Shapefile should be located where it is expected to.

enter image description here

| improve this answer | |
  • 1
    Nice annotation :) – Joseph Jan 30 '15 at 15:57
  • Sorry, This isn't my shape file. It is from example. My shape file is Grid.shp which is on Taiwan. Can you help me again? Now, I put it on Website. – Seventysecond Feb 1 '15 at 6:12
  • OK this way is working on the other shape file. Thanks a lot. – Seventysecond Feb 1 '15 at 6:15

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.