[OpenLayers-Users] Problem with Mapserver + PostGIS + Openlayers

Arnd Wippermann arnd.wippermann at web.de
Sat May 2 13:43:20 EDT 2009


Hi,
 
add maxResolution and maxExtent to your map declaration, then it should
work.
 
map = new OpenLayers.Map('map', {
...
maxResolution: Math.abs(117107.3758-940177.4915)/256,
maxExtent: new OpenLayers.Bounds(117107.3758, 11491.8435, 940177.4915,
326719.7326),
...
 
the bounds come from :  <http://spatialreference.org/ref/epsg/32119/>
http://spatialreference.org/ref/epsg/32119/
 
*  WGS84 Bounds: -84.3200, 33.8000, -75.4300, 36.5800
* Projected Bounds: 117107.3758, 11491.8435, 940177.4915, 326719.7326
* Scope: Large and medium scale topographic mapping and engineering survey.
* Last Revised: 2007-01-19
* Area: USA - North Carolina

By the way. In the mapfile you should use extent in the same projection as
your map projection, also it doesn't effect the output.
 
Arnd
 
 
  _____  

Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von cole gillespie
Gesendet: Samstag, 2. Mai 2009 01:59
An: users at openlayers.org
Betreff: [OpenLayers-Users] Problem with Mapserver + PostGIS + Openlayers


Users,

I am having trouble with my Openlayers map. I have a mapfile that I am
trying to view inside of Openlayers. I feel like I am doing every thing
right but all I am getting to show up inside of Openlayers is a white image.
Below I will include both my map file and my openlayers html file. Any
suggestions on what I am doing wrong would be greatly appreciated.

///////////////////////////////Mapfile//////////////////////////////////////
/////

MAP
  EXTENT -84.321869 33.752878 -75.400119 36.588157
  FONTSET "fonts/fonts.list"
  IMAGECOLOR 255 255 255
  IMAGETYPE png
  SHAPEPATH "/ms4w/apps/tutorial/data"
  SIZE 800 600
  STATUS ON
  UNITS METERS
  NAME "MS"

  OUTPUTFORMAT
    NAME "png"
    MIMETYPE "image/png"
    DRIVER "GD/PNG"
    EXTENSION "png"
    IMAGEMODE "PC256"
    TRANSPARENT FALSE
  END

  OUTPUTFORMAT
    NAME "AGG"
    MIMETYPE "image/png; mode=24bit"
    DRIVER "AGG/PNG"
    EXTENSION "png"
    IMAGEMODE "RGB"
    TRANSPARENT FALSE
  END

  PROJECTION
    "init=epsg:32119"
  END
  LEGEND
    IMAGECOLOR 255 255 255
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
    END
    POSITION LL
    STATUS OFF
  END

  QUERYMAP
    COLOR 255 255 0
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END

  SCALEBAR
    ALIGN CENTER
    COLOR 0 0 0
    IMAGECOLOR 255 255 255
    INTERVALS 4
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
    END
    POSITION LL
    SIZE 200 3
    STATUS OFF
    STYLE 0
    UNITS MILES
  END

  WEB
    IMAGEPATH "/ms4w/apache/htdocs/tmp/ms_tmp"
    IMAGEURL "tmp/ms_tmp"
    QUERYFORMAT text/html
    LEGENDFORMAT text/html
    BROWSEFORMAT text/html
  END



  LAYER
    CONNECTION "user=postgres dbname=postgis password=help37546"
    CONNECTIONTYPE POSTGIS
    DATA "the_geom FROM (
    SELECT 
    Zipcodes.the_geom AS the_geom, 
    Zipcodes.gid as gid, 
    Zip.income as income
    FROM zipcodes JOIN zip 
    ON zipcodes.zcta = zip.zcta) AS new_table USING UNIQUE gid USING
SRID=-1"
    FILTER "income > 0 and income <= 200000"
    NAME "themelayer"
    PROJECTION
      "init=epsg:32119"
    END
    STATUS ON
    TYPE POLYGON
    UNITS METERS
    CLASS
      STYLE
        ANGLE 360
        COLOR 255 228 181
        OPACITY 100
        SYMBOL 0
      END
    END
  END
END


/////////////////////////////////////openlayers
file///////////////////////////////////////////////////////


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>MapServer Layer</title>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
    <script type="text/javascript">
       
        var map, layer;

       function init(){
    map = new OpenLayers.Map('map', {
    projection: "epsg:32119",
    
    numZoomLevels: 14,
   
    units : "meters",
    controls: [
    new
OpenLayers.Control.ZoomToMaxExtent(),
    new
OpenLayers.Control.PanZoomBar({zoomWorldIcon: true}),
    new
OpenLayers.Control.LayerSwitcher({'ascending':false}),
    new
OpenLayers.Control.MousePosition(),
    new
OpenLayers.Control.MouseDefaults(),
    new
OpenLayers.Control.KeyboardDefaults()
    ]                    
          }); 
   layer = new OpenLayers.Layer.MapServer( "County Map",
       "http://localhost/cgi-bin/mapserv.exe", {map:
"C:/ms4w/Apache/htdocs/test_mapfile_edit.map", layers: "themelayer"} );
      
   map.addLayer(layer);
   
   map.zoomToMaxExtent();
        }
        
    </script>
  </head>
  <body onLoad="init()">
    <div id="title">MapServer Layer</div>
    <div id="tags"></div>
    <div id="shortdesc">Shows MapServer Layer</div>
    <div id="map" class="smallmap"></div>
    <div id="docs">
        
    </div>
  </body>
</html>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090502/1fc7362f/attachment.html


More information about the Users mailing list