views:

122

answers:

1

I use OpenLayers and want to create another navigation-control in the upper-left side. I know how to add Controls, but this navigation is added at default while creating the OpenLayers-Map. So I want to remove that Control, to add an own. I know already, that the default-control is an OpenLayers.Control.PanZoom.

+2  A: 

The map object has a property called controls that is an array of OpenLayers.Control objects. If this property is not explicitly set then OpenLayers will assume that you want the default control set, including OpenLayers.Control.Navigation(), OpenLayers.Control.PanZoom(), OpenLayers.Control.ArgParser(), and OpenLayers.Control.Attribution().

To remove PanZoom or any other default control, simply set the controls property array at the time you construct the Map object. Here is a code example:

var map = new OpenLayers.Map('map', {
    controls: [
        new OpenLayers.Control.Navigation(),
        new OpenLayers.Control.ArgParser(),
        new OpenLayers.Control.Attribution()
    ]
});

Here is a live example.

Please note that by setting the controls property that you will not get any Control objects be default. Any controls you need must be added manually.

Here is a link to the source code of the Map object if you want to see how it works for yourself.

atogle
Thanks. It works :-)
Mnementh