[OpenLayers-Users] OpenLayers + MapServer + Own maps showing miniature tiles

Henrik Collin hcollin78 at googlemail.com
Fri Feb 12 09:14:02 EST 2010


I changed the maxExtent and Resolution and it did some good.

This is how it looks now:

maxResolution: 20000,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34,
20037508.34)

The scale of the map is 1:20000 in meters and that Extent is the max extent
of the epsg:2393. It now draws a box into the map with the background color
defined in the wms.map and the dots I am drawing are in a correct place in
this box. The actual map pictures are still drawn way out of bounds and they
are still too small. 

Am I using the maxResolution correctly? And if not how am I able figure out
the correct resolution?

I also played with the x_0 definitions in the wms.map and that did move the
map, but that is fake solution as far as I am aware.

Thanks in advance!




Christopher Schmidt-2 wrote:
> 
> On Fri, Feb 12, 2010 at 12:14:46AM -0800, Henrik Collin wrote:
>> 
>> Hello,
>> 
>> I am currently trying to build a service that shows a map in a webpage
>> with
>> OpenLayers. The OpenLayers requests the map data from MapServer by using
>> WMS
>> and then draws some features in a layer on top of the map data. 
>> 
>> My main problem is that the loaded map shows as a tiny dot in the screen
>> until I zoom enough. This would be okay if the features would be drawn
>> correctly on the map but alas they are not.  They are off from the
>> position
>> thousands of kilometres. My features are in projection EPSG4326 which is
>> converted to EPSG2393 the map uses. Projections have been setup in both
>> systems MapServer and OpenLayers. 
>> 
>> The map consists of multiple tiles that have been combined to shapefile
>> with
>> MapServers shp2img.exe. When I request the map file form the browser it
>> works perfectly. It returns me the correct piece of the map in the
>> correct
>> tile size.
>> 
>> Does anyone have any idea what am I doing wrong? This is my first try
>> with
>> both services OpenLayers and MapServer so I am not quite sure which one
>> is
>> causing the problems, but as the MapServer returns a correct result when
>> quering directly my educated guess is that the problem lies in the
>> OpenLayers side.
> 
> Your maxExtent and maxResolution are wrong, and unset, respectively.
> You'll need to fix that.
> 
> -- Chris
> 
>> I originally tried the OpenLayers side with Google Maps and got that
>> working
>> ok.
>> 
>> _____________________________________________________________________________________
>> 
>> HTML (In Header):
>> 
>> <script type="text/javascript"
>> src="js/openlayers/OpenLayers.js"></script>
>> <script type="text/javascript" src="js/proj4js/proj4js.js"></script>
>> <script type="text/javascript"
>> src="js/proj4js/defs/EPSG2393.js"></script>
>> <script type="text/javascript"
>> src="js/proj4js/defs/EPSG4326.js"></script>
>> <script type="text/javascript"
>> src="js/proj4js/defs/EPSG900913.js"></script>
>> 
>> _____________________________________________________________________________________
>>                                                                                 
>> OPENLAYERS: (This is not a direct copy of the code as the actual code is
>> written inside multiple MooTools classes and contains a lot of code not
>> needed in here.)
>>                                                                                 
>> var mapOptions = {
>> 				projection: new OpenLayers.Projection("EPSG:2393"),
>> 				units: "m",
>>         // maxResolution: 156543.0339,
>> 	  		maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>> 20037508.34, 20037508.34)
>>  }
>> 
>> var x = 23;
>> var y = 60;
>> var pos = {
>>     lat: x,
>>     lon: y,
>>     zoom: 6
>> };
>> 
>> Method from a class responsible for loading the layers and initializing
>> the
>> map.
>> loadMap: function() {
>>     
>>     // Create map layer
>>     this.map = new OpenLayers.Map(paneMain, mapOptions);
>>     this.map.addControl(new OpenLayers.Control.NavToolbar());
>>     
>>     
>>     /*
>>     this.gphy = new OpenLayers.Layer.Google(
>>         "Google Physical",
>>         {type: G_PHYSICAL_MAP, sphericalMercator: true}
>>     );
>>     this.map.addLayer(this.gphy);
>>     */
>>     
>>     this.wmsserv = new OpenLayers.Layer.WMS(
>>             "WMS Server",
>>            
>> "http://localhost:591/cgi-bin/mapserv.exe?map=/ms4w/apps/service/wms.map&",
>>             {
>>                 layers: "Kartta",
>>                 SRS: "EPSG:2393",
>>                 format: "image/png"
>>             },
>>             { isBaseLayer: true }
>>     );
>>     this.map.addLayer(this.wmsserv);
>>            
>>     // Add Vector Layer on top of the map layer
>>     var vectorStyleMap = new OpenLayers.StyleMap({
>>         graphicZIndex: 100
>>     });
>>     
>>     this.layerLines = new OpenLayers.Layer.Vector("Line Layer", {
>> styleMap:
>> vectorStyleMap, rendererOptions: { zIndexing: true } });
>>     this.map.addLayer(this.layerLines);
>>     
>>     // Add layer controls
>>     selectControl = new OpenLayers.Control.SelectFeature(
>>        this.layerLines,
>>         {
>>             clickout: true, toggle: true,
>>             multiple: false, hover: false,
>>             onSelect: this.LineClick,
>>             onUnSelect: this.LineUnSelect
>>         }
>>     );
>>     this.map.addControl(selectControl);       
>>     selectControl.activate();
>> 
>>     this.map.events.register("zoomend", this, function(e) {
>>         this.redrawDots();
>>     });
>>     
>>     // Center the map
>>     var centerPos = new OpenLayers.LonLat(pos.lon, pos.lat).transform(new
>> OpenLayers.Projection("EPSG:4326"), new
>> OpenLayers.Projection("EPSG:2393"));
>>     this.map.setCenter(centerPos, this.pos.zoom, false, false);
>> },
>> 
>> _____________________________________________________________________________________
>> 
>> WMS.MAP (Settings in the MapServer side) 
>> 
>> MAP
>> 
>>   NAME "Service"
>>   STATUS ON
>>   SIZE 256 256
>>   IMAGECOLOR 128 128 192
>>   # EXTENT 2417774 6720000 2430000 6730000 # Koko kartta
>>   # EXTENT 2427774 6724000 2429000 6726000 # Zoom
>>   # EXTENT 3050187.8969 6585228.0377 3761549.0272 7803095.3519
>>   IMAGETYPE PNG
>>   UNITS METERS
>>   SHAPEPATH "maps/"
>> 
>>   PROJECTION
>>     "init=epsg:2393"
>>     # "proj=tmerc"
>>     # "lat_0=0"
>>     # "lon_0=27"
>>     # "k=1"
>>     # "x_0=3500000"
>>     # "y_0=0"
>>     # "ellps=intl"
>>     #
>> "towgs84=-96.0617,-82.4278,-121.7435,4.80107,0.34543,-1.37646,1.4964"
>>     # "units=m"
>>     # "no_defs"
>>   END
>> 
>>   WEB
>>     IMAGEPATH "/ms4w/tmp/ms_tmp/" 
>>     IMAGEURL "/ms_tmp/"                                   
>>     TEMPLATE "service.html"
>>     LOG "service.log"
>> 
>>     METADATA
>>       "wms_title" "Service"
>>       "wms_onlineresource"
>> "http://localhost:591/cgi-bin/mapserv.exe?map=/ms4w/apps/service/wms.map&"
>>       "wms_srs" "EPSG:4022" 
>>     END
>>     
>>   END
>>     
>>   LAYER
>>     NAME "Kartta"
>>     METADATA
>>        "wms_title" "Map layer"
>>     END
>>     TYPE RASTER
>>     STATUS ON
>>     
>>     TILEINDEX "testshape.shp"
>>     
>>     DUMP TRUE
>>     PROJECTION
>>       "init=epsg:2393"
>>       # "proj=tmerc"
>>       # "lat_0=0"
>>       # "lon_0=27"
>>       # "k=1"
>>       # "x_0=3500000"
>>       # "y_0=0"
>>       # "ellps=intl"
>>       #
>> "towgs84=-96.0617,-82.4278,-121.7435,4.80107,0.34543,-1.37646,1.4964"
>>       # "units=m"
>>       # "no_defs"
>>     END
>>        
>>   END
>>   
>> END
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> View this message in context:
>> http://n2.nabble.com/OpenLayers-MapServer-Own-maps-showing-miniature-tiles-tp4559876p4559876.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
> 
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/OpenLayers-MapServer-Own-maps-showing-miniature-tiles-tp4559876p4561208.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list