[OpenLayers-Users] Adding a Mapserv Layer

Matthew Pulis mpulis at gmail.com
Sat Nov 17 14:43:38 EST 2007


Just would like to add that I changed the code following some more tutorials
I found / examples thanks to Chris, and this is the new code :

<html>
<head>
<title>OpenLayers Example</title>
<script src="http://yancho.no-ip.org/~yancho/OpenLayers.js"></script>


<script defer="defer" type="text/javascript">
//var lon = 164;
//var lat = 162;
var map, layer;



function init(){
var options =
{
maxExtent: new OpenLayers.Bounds(625102.34974933861,215593.742071 ,
656343.383138 ,239014.742071),
maxResolution: 302051/1024,
zoom: 0,
projection: "EPSF:4326",
//'controls': [],
units: "m",
numZoomLevels: 12
};
map = new OpenLayers.Map("map", options);
//map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.LayerSwitcher());


layer = new OpenLayers.Layer.MapServer( "Streets Layer",
"
http://yancho.no-ip.org/~yancho/cgi-bin/mapserv?map=\\home\\yancho\\public_html\\nc\\sample.map&",
{layers : 'streets'}, {gutter: 15});
map.addLayer(layer);

//map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
}



</script>
</head>
<body onload="init()">
<div style="width:800px;height:600px" id="map"></div>

</html>


Pastebin : http://pastebin.com/f50f62c3f

The problem is that when I load the page, there is just the controls, and
the map is not loading. There are no JavaScript errors and I think its just
a problem of the loading of the map.


Link to page : http://yancho.no-ip.org/~yancho/openl.html

Link to how I load the map on mapserv :
http://yancho.no-ip.org/~yancho/cgi-bin/mapserv?map=%2Fhome%2Fyancho%2Fpublic_html%2Fnc%2Fsample.map&imgext=637373.285472+230666.856430+647786.963271+238473.856432&imgxy=200.0+150.0&zoom=0&layer=hospitals&layer=streets&layer=firestations&layer=majorroads&layer=railroads&mode=browse&img.x=164&img.y=62

Any help will be much appreciated. Thanks

Regards


On 11/17/07, Christian López Espínola <penyaskito at gmail.com> wrote:
>
> Hi Matthew,
>
> Your div is named 'map', and you are using
>
> var map = new OpenLayers.Map("basemap", options);
>
> This search for a basemap div, but it doesn't exist.
> Change the div id, or change that line of code.
>
> Hope this helps.
>
> On 11/17/07, Matthew Pulis <mpulis at gmail.com> wrote:
> > Hi,
> >
> > I am a fairly new user to OpenLayers, and this is my project aims :
> >
> > - Want to create a Basemap of streets which is a Vector layer and
> loading it
> > as a MapServ Layer
> > * create a start / end point
> > * create the route
> >
> > (* are not yet started)
> >
> > I am having a problem since after going through the Javascript docs, I
> fixed
> > many of my syntax errors, but am still plagued with this one :
> >
> > this.div has no properties
> > callback("basemap", Object)OpenLayers.js (line 464)
> > Class()OpenLayers.js (line 57)
> > init()openl.html (line 24)
> > onload(load )openl.html (line 1)
> > [Break on this error] this.active=false;return
> > true;},callback:function(name,args){if(this.callbacks[n...
> >
> > Error found @ OpenLayers.js (line 464) .. Error reporting by FireBug of
> > FireFox
> >
> > The code I am working upon is a mix of viewsourcing some pages and the
> > tutorials :
> >
> > <html>
> > <head>
> >  <title>OpenLayers Example</title>
> >  <script
> > src="http://yancho.no-ip.org/~yancho/OpenLayers.js"></script>
> >
> >
> >  <script defer="defer" type="text/javascript">
> >  function init(){
> >  var options =
> >  {
> >  maxExtent: new OpenLayers.Bounds(625102.34974933861,215593.742071
> > ,656343.383138 ,239014.742071 ),
> >  maxResolution: 302051/1024,
> >  zoom: 2,
> >  projection: "WGS84",
> >  'controls': [],
> >  units: "m",
> >  numZoomLevels: 12
> >  };
> >  var map = new OpenLayers.Map("basemap", options);
> >  var options2 =
> >  ( {name : "Streets Layer"},
> >  {url : "http://yancho.no-ip.org/~yancho/cgi-bin/mapserv"},
> >  {params : "\\home\\yancho\\public_html\\nc\\sample.map"},
> >  {options : []}
> >  );
> >  map.addLayer (new OpenLayers.Layer.MapServer("streets", options2));
> >
> >  }
> >
> >  </script>
> >  </head>
> > <body onload="init()">
> > <div style="width:800px;height:600px" id="map"></div>
> >
> > </html>
> >
> > If you want the code with syntax highlighted you can go here :
> > http://pastebin.com/f218a9fc9
> >
> >
> > I would be extremely happy if you manage to point me to any errors I am
> > doing, and maybe some other reading I should do.
> >
> > Thanks alot for your time in reading my post
> >
> >
> > Regards
> >
> >
> > Matthew
> >
> > --
> > Matthew Pulis
> > URL : http://www.solutions-lab.net
> > MSN : pulis_matthew[@]hotmail.com
> > ICQ : 145951110
> > Skype : solutions-lab.net
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
>
>
> --
> Regards,
>
> Christian López Espínola
>



-- 
Matthew Pulis
URL : http://www.solutions-lab.net
MSN : pulis_matthew[@]hotmail.com
ICQ : 145951110
Skype : solutions-lab.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071117/03afa90b/attachment.html


More information about the Users mailing list