[OpenLayers-Users] Display maps in OL from mapserver
Julien-Samuel Lacroix
jlacroix at mapgears.com
Tue May 6 10:48:24 EDT 2008
Hi,
Try with the extents of your mapfile in the maxExtent option:
var bounds = new OpenLayers.Bounds(114.327181, 30.454108, 114.363140,
30.495525)
map = new OpenLayers.Map( 'map', {maxExtent: bounds});
Then after addLayer zoom on that extent:
map.addLayer(layer);
map.zoomToExtent(bounds);
Julien
Chen kuja wrote:
> Thanks for your helpful tip. I saw this format from a old post, so i
> thought it might be the right way to do with mapfile. Anyway, after
> changing the code, the worldmap file(from tutorial) works pretty well.
> But my file's output turned into an odd way. like in this screenshot
> http://img.album.pchome.net/00/06/47/89/4450279983314c88777d269a340264a6.png
> Within the border, only a little dot exits.
>
> Projection issue, I know this from FAQ and some old posts. But still, I
> can't understand. My shp files were built under WGS84. And I want to
> integrate my base map and google earth's hybid image. So I chose
> longitude&latitude as my extend. Openlayer's default projection type is
> epsg 4326 which matches WGS84, right?
>
> Besides, the extent vaules in either my mapfile or worldmap's is in
> latitude&longitude format.
> this is image link of my mapfile's
> http://127.1/cgi-bin/mapserv.exe?layers=Shp_Lakes&map=%2Fms4w%2Fapps%2Fmap.map&mode=map&map_imagetype=png&mapext=112.5+22.5+123.75+33.75&imgext=112.5+22.5+123.75+33.75&map_size=256+256&imgx=128&imgy=128&imgxy=256+256
> <http://127.1/cgi-bin/mapserv.exe?layers=Shp_Lakes&map=%2Fms4w%2Fapps%2Fmap.map&mode=map&map_imagetype=png&mapext=112.5+22.5+123.75+33.75&imgext=112.5+22.5+123.75+33.75&map_size=256+256&imgx=128&imgy=128&imgxy=256+256>
> and the mapfile
>
> MAP
> NAME hzau
> # Map image size
> SIZE 800 800
>
> EXTENT 114.327181 30.454108 114.363140 30.495525
> PROJECTION
> 'proj=longlat'
> 'ellps=WGS84'
> 'datum=WGS84'
> 'no_defs'
>
> world map's
> http://127.1/cgi-bin/mapserv.exe?layers=Shp_Lakes&map=%2Fms4w%2Fapps%2F123.map&mode=map&map_imagetype=png&mapext=-90+0+-45+45&imgext=-90+0+-45+45&map_size=256+256&imgx=128&imgy=128&imgxy=256+256
> <http://127.1/cgi-bin/mapserv.exe?layers=Shp_Lakes&map=%2Fms4w%2Fapps%2F123.map&mode=map&map_imagetype=png&mapext=-90+0+-45+45&imgext=-90+0+-45+45&map_size=256+256&imgx=128&imgy=128&imgxy=256+256>
> also the mapfile
> NAME world
> # Map image size
> SIZE 800 800
>
> EXTENT -179.999900 -90 179.999900 90
> PROJECTION
> 'proj=longlat'
> 'ellps=WGS84'
> 'datum=WGS84'
> 'no_defs'
>
> I guess with the openlayer's default extent, the export image should be
> a little small, not a dot(still a dot after zooming for 5 times)
> Or I should just set extent manually?
>
> best wish
>
> 2008/5/6 Christian López Espínola <penyaskito at gmail.com
> <mailto:penyaskito at gmail.com>>:
>
> Hi Chen,
>
> On Tue, May 6, 2008 at 8:31 AM, Chen kuja <eiclkun at gmail.com
> <mailto:eiclkun at gmail.com>> wrote:
> > map = new OpenLayers.Map( 'map' );
> > layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
> > "http://127.1/cgi-bin/mapserv.exe?", { layers:
> > 'Shp_Lakes',
> > map: 'map=/ms4w/apps/map.map'} );
> > map.addLayer(layer);
>
> Try with
> > map: '/ms4w/apps/map.map'} );
> > map.addLayer(layer);
>
>
> --
> Regards,
>
> Christian López Espínola
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/
More information about the Users
mailing list