1

My code says the error "undefined input"? I don't know what is wrong with my code:

<!doctype html> <html> <head> <title>Map Examples</title> <link rel="stylesheet" href="../assets/ol3/css/ol.css" type="text/css" /> <link rel="stylesheet" href="../assets/css/samples.css" type="text/css" /> </head> <body> <div id="map" class="map"></div> <input type="checkbox" id="visible" checked> Toggle Layer Visibility <script src="../assets/ol3/js/ol.js"></script> <script> var layer = new ol.layer.Tile({ source: new ol.source.OSM() }); var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857'); var view = new ol.View({ center: london, zoom: 6 }); var map = new ol.Map({ target: 'map', layers: [layer], view: view }); // create a DOM Input helper for the checkbox var visible = new ol.dom.Input(document.getElementById('visible')); // and bind its 'checked' property to the layer's 'visible' property visible.bindTo('checked', layer, 'visible'); </script> </body> </html>

  • Are you using a custom build? – Jonatas Walker Jun 23 '15 at 10:46
  • Dear Jonatas, thank you for your answer, I am just new in developing a GIS web page, but as I understand the meaning of custom build, I downloaded the latest release of java script from openlayer site, and put it my folder. this code is one of the examples of "OpenLayers 3 Beginner's Guide" book. the link is : link. the code works on the page but when I copy the exact code on my pc it doesnt work. – Negin Jun 23 '15 at 11:30
2

The bindTo method was removed from ol.Object in version 3.6.x. See https://github.com/openlayers/ol3/pull/3472 for further details.

You can use the layer group example to see how to bind inputs in a more generic way. This example uses jQuery to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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