Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi all it seems like I am having difficulties in normalizing raw map files' resolutions to openlayer's use most probably in parameters mapext and imgext. I hope you can help me with this.

Using raw (.shp, .shx, .xml, .prj, .dbf) and associated raster files for landuse-related data included in an ArcGIS 10 project (.mxd) that I've obtained from a credible private source, I have used Mxd2Qgs to read .mxd project to .qgs. Then I used quantum GIS' Mapserver Export plugin to export selected layers to MAP FILE.

I can view the generated map on browser but cannot do so when I use it in openlayers. The generated map file has an extent: EXTENT 272813.696194 1546212.773835 340292.781152 1587773.606956 (its quite huge).

I have tried adding to openlayer's map initialization properties maxResolution, numZoomLevels, units, projection and displayProjection but there is no map rendered, although the map has been queried. Btw I have just guessed the maxResolution here, copying from other huge datasets online :) The map has never been queried when I added the map file's EXTENT to maxExtent: OpenLayers.Bounds(...). The same thing goes when I used the files included in the MS4W tutorial #1 data set.

My questions would be:

  • How to know a given map's maxResolution parameter for openlayers? Can this be guessed?
  • Are there any special processing needed for map/shapefiles before they can be used in openlayers?
  • How should a map file be written so that it could be used in openlayers?

Thank you so much in advance for your tips.

EDIT: Attached MAP FILE and javascript files.

share|improve this question

You can use maxResolution: 'auto', if you dont know your maxresolution. it is how many "units" does a pixel on the screen represent.

if you want to calculate it you can use this formule: (details are here)

Units Conversion Factor
inches        1
ft           12

mi        63360
m       39,3701
km      39370,1
dd      4374754      Decimal Degrees

Map DIV               The size of the area on the webpage the map will go in.
WIDTH         600     pixel
HEIGHT        600     pixel

Units        dd      Units our map is in for OpenLayers            
Factor  4374754      Scale factor based on units.

dx         = Left - Right
Scale      = dx/WIDTH * dpi * Factor


Resolution = Scale / ( dpi * factor ) = 4000000 / ( 72 * 4374754  ) = 0.012699

with your que. about shapefile, you can use directly shapefile in openlayers with Openlayers shapefile method.


but i suggest that you should use geojson format from server or local for getting faster performans and more browser compatibility which i have been using it for a long time. You can easily convert your data to geojson with qgis. Besides this, javascript shapefile viewer is another choose. Some example pls see here and Convert Shapfiles and DBF to GeoJSON using JavaScript here.

i hope it helps you...

share|improve this answer
Thank you for your hints about the conversions Aragon these are very helpful. I'm using MAP FILES now but with your suggestion I will try them out as GeoJSON for faster performance. Finally I got the MAP FILE to render nicely in openlayers. – tarrent Apr 29 '12 at 14:51
Sorry for the delayed comment this should have been included on the previous. I've accidentally pressed Enter. The error in my first attempt was my MAP FILE's contents and openlayers' map initialization wasn't in sync and I was using the wrong projection :D initialization should have been link Thanks a lot again. Now I can move on with my newbie adventure in mapserver and openlayers :) – tarrent Apr 29 '12 at 15:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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