Version 21 (modified by tschaub, 6 years ago)

adding link to Natural Docs conventions

OpenLayers JavaScript API Documentation

Automatically generated API documentation is available from  JSDoc on dev.openlayers.org.

API documentation generated by Natural Docs will soon be available. See Natural Docs conventions if you are contributing code.

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

Automatically generated API documentation is available from  JSDoc on dev.openlayers.org.

This documentation needs to be fleshed out still.