- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写有效的办公室定位器。作为其中的一部分,我想在初始位置的一定半径内添加标记,并将图钉放在剑道 map 控件上。
jsfiddle 在这里 http://jsfiddle.net/3whk8mm2/
我有下面的函数,它使用半正矢距离计算来过滤 officeLocations 数组。
self.filteredOffices = ko.computed(function() {
if(self.searchRadius() > 0)
{
var result = ko.utils.arrayFilter(self.officeLocations(), self.filter);
return result;
}
});
map 本身是使用以下选项创建的:-
self.mapOptions = {
center: [53.4809500, -2.2374300],
zoom: 5,
layers: [
{
type: "tile",
urlTemplate: "http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png",
subdomains: ["a", "b", "c"],
attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>"
}, {
type: "marker",
dataSource: self.filteredOffices, //works if put self.officeLocations() directly
locationField: "address.location",
titleField: "name"
}],
}
我知道filteredOffices 集合已正确填充,因为 map 上方有一个div 包含正确的结果。
我不明白的是为什么过滤后的办公室没有显示在 map 上?
任何帮助将不胜感激
最佳答案
标记不会更新,因为 dataSource
选项无法绑定(bind)到 observable。作为文档 says observables 仅适用于 center
、zoom
和 widget
选项。
要更新您的 map ,您可以订阅 self.filteredOffices
的更改:
self.filteredOffices.subscribe(function(value) {
$('.map').data('kendoMap').layers[1].dataSource.data(value);
})
关于javascript - 使用 ko.compulated 和 kendoMap 绑定(bind)动态添加标记到 kendoMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32989889/
我的 MVC 布局中有以下内容(在底部): @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @Sc
我们正在做一个机器人项目,我们将使用相机(ArtCam 130MI)在 Ubuntu 12.04 上进行图像处理,该公司已终止对 Linux 的支持,但向我们发送了编译驱动程序的源代码,但在 load
这两个函数都允许替换/修改绑定(bind)上下文并将其应用于未绑定(bind)的节点。 “未绑定(bind)”表示我自己的自定义绑定(bind)想要使用这些有用的功能必须总是返回 { controls
我正在尝试使用计算来计算某些产品的总和。 function productViewModel(){ self = this; function productModel(data)
我正在尝试将 View 模型序列化为 JSON 以发送回我的服务器,但收到以下错误。 Uncaught Error: Pass a function that returns the value of
我有一个问题。请帮帮我。我有 ko.compulated,它有一个检查 ko.isObservable 变量,我需要 ko.compulated 不对这个变量的更改使用react。请参阅示例: ko.
两者都用于在 View 模型上应用 knockout 验证配置。这两种说法有什么不同? 谢谢 最佳答案 我看起来像配置是为了向后兼容,只是调用 init。 来自验证源( https://github.
ko.validation.group有什么区别和 ko.validatedObservable ?当我应该使用一种而不是另一种时,是否有特殊情况? 最佳答案 ko.validation.group只
我在尝试用 requirejs 很好地进行 knockout 时遇到了问题(从这里的帖子数量来看,其他人也是如此!)。我在这里读到的任何内容都没有遇到过这个问题。 以下是我的require配置: re
背景 Trevor 有一个简单的 knockoutjs 页面,包含三个声明的 ko.observable() 和一个声明的 ko.computed() 问题 Trevor 想删除第三个声明的项目。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我是knockout js的新手,我想将knockout.js与asp.net表单应用程序一起使用。我想使用 ajax 调用更新实体,如下所示 // Update product details
我使用 kogrid 显示数据,如下所示: 我的 knockout 虚拟机对 MVC Controller 进行 ajax 调用,以检索形状如下的 DTO: 我想将具有验证失败的值的单元格背景涂成红色
我在使用 KOgrid 时遇到两个问题。 1)我无法在kogrid中获取滚动条。没有滚动条很难进行数据输入。 2)如果不指定硬编码的高度和宽度,我也无法让 kogrid 工作。在我的应用程序中,我不能
我从加载的列表中获取一些数据并将它们添加到可观察数组中,我想将它们显示在另一个列表中,除了数据未显示在屏幕上之外,一切都会进行这是代码 self.addData = function (val) {
我有一个像这样的 ko maaaped 数组。 var Type = []; Type.push("Flip"); Type.push("Bar")
我有一些正在处理的代码是一个更大的预算应用程序的一部分。该位允许用户输入一些每周重复发生的费用,应用程序将根据输入计算每月总计。除了在编辑现有条目时更新表中的每月金额外,一切正常。删除功能会更新每月每
我得到: Uncaught TypeError: Cannot call method 'applyBindings' of undefined 我查看了 chrome 中的“网络”选项卡,发现已加载
我有一张 map ,其中有一个元素显示当前正在加载哪些图层。我在一个可移除的可观察数组中保存了一个层名称列表。加载新图层时,它们会按预期显示。当层完成加载时,它们将按预期移除,除了最后一个。即使调试显
我试图了解保持可观察函数或将其设置为对象之间的区别 我的可观察项目: self.SelectedItem = ko.observable(); 我的观点: @Html.Action("P
我是一名优秀的程序员,十分优秀!