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?

closed as off-topic by nmtoken, Midavalo Dec 3 '17 at 22:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – nmtoken, Midavalo
If this question can be reworded to fit the rules in the help center, please edit the question.


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..
  • 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.