I have a problem with OpenLayers controls. I have two controls which are perfectly working,

var mousePositionControl = new ol.control.MousePosition({
        coordinateFormat: ol.coordinate.createStringXY(6),
        projection: 'EPSG:4326',
        // comment the following two lines to have the mouse position
        // be placed within the map.
        className: 'custom-mouse-position',
        target: document.getElementById('mouse-position'),
        undefinedHTML: 'Haritada degilsiniz.'
    var scaleLine = new ol.control.ScaleLine();


controls: ol.control.defaults().extend([mousePositionControl, scaleLine])

But when I try add fullscreen control as a third one, like this:

var fullScreen = new ol.control.FullScreen();

and edit controls like this:

controls: ol.control.defaults().extend([mousePositionControl, scaleLine, fullScreen])

it's not working and also I lose map.on('click', function(event)){...} functions.

By the way I try to add only FullScreen control, it works. Have a limitation there of adding controls on OpenLayers 3?


I think you may need to add custom controls to default ones instead of extending it.
Can you try like this ?

controls: ol.control.defaults({}, [
   new ol.control.FullScreen(),
   ..others if you want to..
| improve this answer | |
  • Thanks for your answer, it's not working. FYI. But I try map.addControl(new ol.control.FullScreen()); and it's work perfectly. – serifsadi Oct 14 '14 at 8:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.