Version 9 (modified by xavid, 7 years ago)

Correcting OpenLayers.Layer.Marker to OpenLayers.Layer.Markers

OpenLayers JavaScript API Documentation

Some code samples: Hello World example:

<html>
<head>
<script src="http://openlayers.org/api/2/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://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
    map.addLayer(wms);
    map.zoomToMaxExtent();
  </script>
</body>
</html>

Add a LayerSwitcher control:

    map.addControl(new OpenLayers.Control.LayerSwitcher());

Add a TextFile Layer:

    map.addLayer(new OpenLayers.Layer.Text("Data", "datafile.txt"));

Add a Markers Layer, and create a marker:

    var markersLayer = new OpenLayers.Layer.Markers("Some Points of Interest");
    var marker = new OpenLayers.Marker(
        new OpenLayers.LonLat(5,10), 
          new OpenLayers.Icon(
           "http://openlayers.org/api/img/marker.png", 
           new OpenLayers.Size(10,15)
          ));
    markersLayer.addMarker(marker);
    map.addLayer(markersLayer);

Incomplete API Documentation

This documentation needs to be fleshed out still.

Attachments