0

I am new to openlayers and am trying to show the gml layer in my browser with everything from the hard drive. I have tried the following code but could not for the life of me get it to work. The xml file can be downloaded from: ftp://webftp.vancouver.ca/opendata/xml/weekendplayfieldstatus.xml . It was placed in the same directory as my html file. Thanks in advance for any help.

Dan

<html>
<head>
  <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    </head>
    <body>
      <div style="width:100%; height:100%" id="map"></div>
      <script defer="defer" type="text/javascript">
        var map = new OpenLayers.Map('map');
        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
            "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
        var fromProjection = new OpenLayers.Projection("EPSG:4326");   // Transform from WGS 1984
        var toProjection   = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
    var layer = new OpenLayers.Layer.GML("GML", "weekendplayfieldstatus.xml");
    var position       = new OpenLayers.LonLat(-123.1000,49.2500);
        var zoom           = 11; 
    var markers = new OpenLayers.Layer.Markers( "Markers" );


    map.addLayer(wms);
    map.setCenter(position, zoom);

    map.addLayer(markers);
        markers.addMarker(new OpenLayers.Marker(position));

      </script>
    </body>
</html>
Dan
  • 11
  • 3

1 Answers1

0

I believe you are simply missing the call to add the GML layer to the map.

var layerGML = new OpenLayers.Layer.GML("GML", "weekendplayfieldstatus.xml");    
map.addLayer(layerGML);
Frank Phillips
  • 95
  • 1
  • 11