- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题,切换复选框不起作用,控制台显示如下。 代码:
<!doctype html>
<head>
<title> Me OpenStreetMap </title>
<link rel="stylesheet" href="../assets/ol3/css/ol.css" type="text/css" />
<link rel="stylesheet" href="../assets/ol3/css/samples.css" type="text/css" />
</head>
<body>
<div id="map"></div>
<input type="checkbox" id="visible" checked />Toggle layer Visibility
<script src="../assets/ol3/js/ol.js"></script>
<script>
var center = new ol.proj.transform([11.57,3.86], 'EPSG:4326','EPSG:3857');
var view = new ol.View({
zoom: 6,
center: center
});
var layer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var map = new ol.Map({
target: 'map',
layers: [layer],
view: view
});
// bind a checkbox with id 'visible' to a layer's visibility
var visible = new ol.dom.Input(document.getElementById('visible')); /* line 30 */
visible.bindTo('checked', layer, 'visible');
</script>
</body>
</html>
map 出现了,但是复选框没有反应,控制台日志说:
Uncaught TypeError: Cannot read property 'Input' of undefined
(anonymous function) @ events.html:30
我经历了这个,但我还是不明白 OpenLayers - Uncaught TypeError: Cannot read property 'div' of undefined
最佳答案
如果要使用此功能,请确保您的库版本低于 3.5.0,因为 ol.dom.Input
已在 3.5.0 版本中删除:https://github.com/openlayers/ol3/releases/tag/v3.5.0
The experimental ol.dom.Input component has been removed. If you need to synchronize the state of a dom Input element with an ol.Object, this can be accomplished using listeners for change events. For example, you might bind the state of a checkbox type input with a layer's visibility like this:
var layer = new ol.layer.Tile();
var checkbox = document.querySelector('#checkbox');
checkbox.addEventListener('change', function() {
var checked = this.checked;
if (checked !== layer.getVisible()) {
layer.setVisible(checked);
}
});
layer.on('change:visible', function() {
var visible = this.getVisible();
if (visible !== checkbox.checked) {
checkbox.checked = visible;
}
});
关于openlayers bindTo 事件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31501924/
我有一个问题,切换复选框不起作用,控制台显示如下。 代码: Me OpenStreetMap Toggle layer Visibility
我是 AngularJs 的新手,现在我正在尝试使用 Firebase。 这是我的 Firebase 数据: pavlovdog | ---facebook: "facebook.pavlovdog
我正在尝试在 Swift 2.0 中构建一个照片共享应用程序,我使用 carthage 将 SWIFTBOND 引入我的 xcode 项目,但不幸的是我遇到了这个问题。 var post: Post?
在 Swift3 中我遇到了一个问题: @IBOutlet weak var connectButton: UIButton! [...] viewModel.connectButtonTitle.a
当我尝试将第一个 map 的 View 绑定(bind)到第二个 map 时,收到此错误消息。所以,我有两张 map - mapOne 和 mapTwo。当我不进行任何绑定(bind)时,它们工作得很
例如,我有一些代码: class A { private $value = 100; } $a = new A; $closure = function(){echo $this->value
我最近开始为我的 Angular JS 探索 Firebase。我有两个片段, var ref = new Firebase("https://my-firebase-id.firebasei
我在 .NET 4.5 中使用 RXUI 6 和 WPF。 当它绑定(bind)到的 ViewModel 属性由 ObservableAsPropertyHelper 支持时,我一直无法获得提供给我的
我有一个读写属性 private string _serialNumber; public string SerialNumber { get => _seri
如何在对象上调用 angularfire 的 $bindTo() 后从 firebase 中删除对象。出于某种原因,调用 $bindTo() 似乎从对象中删除了 $remove() 函数。 例如,除非
userView = Marionette.View.extend tagName: "h1" initialize:-> @bindTo @model, "change:name",
ToProperty() 似乎用于基于可观察对象的只读属性,但我什么时候想使用 BindTo()? 最佳答案 ToProperty 用于 ViewModel,而 BindTo 更灵活一些,旨在用于应用
我正在尝试更新 View XAML 中元素的属性: this.WhenAnyValue(x => x.ViewModel.IsEnabled).BindTo(this, x => x.MyButton
我是学习 RxSwift 的新手。 我修改了 RxSwift Example App 中的 Simple Numbers 示例,它将三个数字添加到一个结果数字中。 我添加了一个 testStr UIT
我正在尝试将 Kendo AutoComplete 绑定(bind)到 View 模型。我似乎无法将其设置正确。这就是我尝试绑定(bind)到模型属性列表的方式 该属性是模型的集合,如下所示: @Ht
我是 OpenLayers 的新手。我正在尝试使用 3.0 和 3.13 版本做一些练习。 我必须链接两个 View :第二张 map 响应第一张 map 的变化,但缩小了三倍;当平移或缩放第一张 m
这次我正在努力使用不同的方法来绑定(bind)事件。我的代码中有所有提到的方法。我只是不知道,如果我走对了。也许我应该总是使用 bindTo 来确保我的 View 在更改后完全关闭(目前这通常会产生错
我试图通过在他们的官方页面上构建这个示例代码来取消绑定(bind) Open Layers 3 中的并排 map : http://ol3js.org/en/master/examples/side-
我正在学习 Kendo UI。我们正在努力将 Kendo UI 用于 MVC 应用程序 View 中的所有内容。 我正在尝试绑定(bind)到 Kendo 网格每一行中的模型对象内的集合。我们使用 E
我使用 RxSwift绑定(bind)我的 viewmodel至 UILabel和 UITexfield . UITextfield转换为 Swift 3 没有问题, 只是替换 rx_text与 rx
我是一名优秀的程序员,十分优秀!