OpenLayers 0.6.6

From Mapping on MediaWiki
Jump to: navigation, search
OpenLayers 0.6.6
OpenLayers is an open source (provided under a modified BSD license) JavaScript library for displaying map data in web browsers.
OpenLayers 0.6.6 licence
Parameter value:
Parameter aliases:
layers, openlayer
More info:
OpenLayers 0.6.6

OpenLayers 0.6.6 is one of the mapping services natively supported by the Maps and Semantic Maps extensions. It can be used with:

OpenLayers specific properties

This mapping service defines several of it's own parameters that are supported by most of the features implementing this service.

Property Aliases Default Version
layers - configurable Changed in 0.5.4
controls - configurable Changed in 0.4


Parameter: layers=

Notice: The values for this parameter and how they are handles have changes in 0.5.4. For older releases, see this version of this page.

Available values

  • bing - All available Bing Maps (formerly known as Virtual Earth) map types
    • bing-normal - Bing streets
    • bing-satellite - Bing satellite
    • bing-hybrid - Bing hybrid
  • yahoo - All available Yahoo! Maps map types
    • yahoo-normal - Yahoo! streets
    • yahoo-satellite - Yahoo! satellite
    • yahoo-hybrid - Yahoo! hybrid
  • osm - All available OpenStreetMap map types
    • osmarender - OSM arender
    • osm-mapnik - OSM Mapnik
    • osm-cyclemap - OSM Cycle Map
  • openlayers-wms - OpenLayers WMS
  • nasa - NASA Global Mosaic

How it works

This parameter sets the available base layers of your OpenLayers map. You can add as many base layers as you want, by separating them with comma's. When you add a layer twice, only the first occurrence will be added. The google, bing, yahoo and osm short cuts allow you to add all their associated layers without having to type them individually. You can configure the default layers (the ones that will be added when no value is provided) in the settings file. The first layer will be loaded at start-up.

Extra dependencies

Adding certain layers will make the OpenLayers map dependent on other mapping API's. Those are listed below:

  • All Google layers - require the Google Maps API. You must have a valid Google Maps API key entered for these layers to work!
  • All Yahoo! layers - require the Yahoo! Maps API. You must have a valid Yahoo! Maps API key entered for these layers to work!


This is a simple example with 3 layers.


This example demonstrates the usage of the bundle short-cuts.


This will result in the following order of layers:

Google hybrid, NASA Global Mosaic, Yahoo! streets, Yahoo! satellite, Yahoo! hybrid, Google streets, Google satellite maps, Google physical maps

Google Maps layers

To be able to use Google Maps layers, you need to add the following lines to your LocalSettings file, after the inclusion of Maps, and any API keys. Check out the demo's for examples.

# Google Maps layers for OpenLayers
$egMapsOLAvailableLayers['google-normal'] = array('OpenLayers.Layer.Google( "Google Streets", {"sphericalMercator":true} )', 'google');
$egMapsOLAvailableLayers['google-satellite'] = array('OpenLayers.Layer.Google( "Google Satellite", {type: G_SATELLITE_MAP , "sphericalMercator":true} )', 'google');
$egMapsOLAvailableLayers['google-hybrid'] = array('OpenLayers.Layer.Google( "Google Hybrid", {type: G_HYBRID_MAP , "sphericalMercator":true} )', 'google');
$egMapsOLAvailableLayers['google-physical'] = array('OpenLayers.Layer.Google( "Google Physical", {type: G_PHYSICAL_MAP , "sphericalMercator":true} )', 'google');
$egMapsOLLayerGroups['google'] = array('google-normal', 'google-satellite', 'google-hybrid', 'google-physical');
$egMapsOLLayerDependencies['google'] = "<script src=';v=2&amp;key=$egGoogleMapsKey&amp;hl={}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions.min.js?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>";

This will make these values available:

  • google - All available Google Maps map types
    • google-normal - Google streets
    • google-satellite - Google satellite
    • google-hybrid - Google hybrid
    • google-physical - Google physical

Defining your own layers

Since Maps 0.5.4, you can define your own layers. This is done by adding extra values to $egMapsOLAvailableLayers, $egMapsOLLayerGroups and $egMapsOLLayerDependencies in your LocalSettings file. See the demo's for several examples and a collection of already defined custom layers you can use. Please add your own layers there, so other people can also use them. They might even end up in Maps core if they are requested by multiple users.

In most cases, you'll just need to add a single line, setting a new value for egMapsOLAvailableLayers. This line can be obtained by looking at the source of the page containing a map that has the layer you also want to use. It'll contain an assignment, like for example

somevar = new OpenLayers.Layer.OSM("Öpnv Deutschland", "${z}/${x}/${y}.png", {numZoomLevels: 19,displayInLayerSwitcher:false,buffer:0});

You need this part from it (basically the thing that's being assigned, without the 'new' keyword and semicolon at the end)

OpenLayers.Layer.OSM("Öpnv Deutschland", "${z}/${x}/${y}.png", {numZoomLevels: 19,displayInLayerSwitcher:false,buffer:0})

Your layer definition in LocalSettings should then look similar to this, where 'german-layer' is the layer name you'll need to enter to get this layer on your map.

$egMapsOLAvailableLayers['german-layer'] = array('OpenLayers.Layer.OSM("Öpnv Deutschland", "${z}/${x}/${y}.png", {numZoomLevels: 19,buffer:0})');

As you can see, I removed displayInLayerSwitcher:false, which would prevent the layer from showing up in the layer switcher. You can of course retain this if it's the desired effect. Also note that you can change the name of the layer (as displayed in the layer switcher), by changing the value which is here "Öpnv Deutschland".

If you want to create more complex custom layers, and do not have the JS/PHP experience to figure out how yourself, or otherwise have problems creating your own custom layers, just give me a poke, and I'll help you out -- Jeroen De Dauw


Parameter: controls=

Available values: See the OpenLayers docs (the items in the menu on the left).

This parameter sets the controls that will be added to your OpenLayers map. You can add as many of the controls you want, by separating them with comma's. You can also configure the default controls (the ones that will be added when no value is provided) in the settings file.

See the OpenLayers docs for a list of available controls and their descriptions. Note that the value of the controls parameter is case insensitive, so it doesn't matter if you use capitals or only lower case letters.

Since 0.4, Maps supports the 'autopanzoom' control. When you specify this control, Maps will automatically determine if panzoom, panzoombar, or no control should be used, depending on the maps height.

Example of how to use this parameter:


OpenLayers specific settings

OpenLayers layers

The default layers for OpenLayers. This value will only be used when the user does not provide one. See the layers parameter for the available values.

Default: $egMapsOLLayers = array('openlayers');

OpenLayers controls

The default controls for OpenLayers. This value will only be used when the user does not provide one. See the controls parameter for the available values.

Default: $egMapsOLControls = array('layerswitcher', 'mouseposition', 'panzoombar', 'scaleline', 'navigation');

Default map zoom

The default zoom of an OpenLayers map. This value will only be used when the user does not provide one.

Default: $egMapsOpenLayersZoom = 10;

Map name prefix

The OpenLayers map name prefix. It can not be identical to the one of another mapping service. Unless you know what you are doing, it's discouraged to modify this value.

Default: $egMapsOpenLayersPrefix = 'open_layer';

This documentation page applies to all (Semantic) Maps versions from 0.1 to 0.6.6.
Other versions: ≥ 1.0, 0.7 – 0.7.x      

OpenLayers en 0.1 0.6.6

Facts about "OpenLayers 0.6.6"RDF feed
From version0.1 +
Has descriptionOpenLayers is an open source (provided under a modified BSD license) JavaScript library for displaying map data in web browsers. +
Has licence +
Has main parameteropenlayers +
Has parameter aliaslayers + and openlayer +
Has url +
Is master pagefalse +
Language codeen +
Master pageOpenLayers +
To version0.6.6 +