按openlayer 3中的位置名称放大
Zoom in to by name of location in openlayer 3
我正试图通过动态选择框按州>地区>村庄的顺序按名称放大到位置。
在这篇文章中,我创建了两个名为zoomToExtDist(name)
和zoomToExtVil(distname,vilname)
的函数。但不知道它们不起作用。我们应该在openlayers 3中使用哪个函数。有人能告诉我哪里做错了吗。这是我创建的plunker缩放到位置更新链接
请告诉我在openlayers 3中,我们应该使用哪个函数来设置通过lat-long的视图。提前感谢:)
试试这个
$(function() {
var records = jsonList.listval;
// console.log(records);
insert($('#state_id'), plucker(records, 'state'));
//------------------------^ grabs unique states
//--^ populate state list on DOM ready
$('select').on('change', function() {
var category = this.id.split('_id')[0];
var value = $(this).find('option:selected').text();
switch (category) {
case 'state':
{
insert($('#district_id'), plucker(filter(records, 'state', value), 'district'));
break;
}
case 'district':
{
insert($('#village_id'), plucker(filter(records, 'district', value), 'village'));
break;
}
case 'village':
{
zoomToExtDist($(this).val());
break;
}
}
});
function zoomToExtDist(name)
{ console.log(name);
for (var i = 0; i < jsonList.listval.length; i++)
{
if(name==jsonList.listval[i].village)
{
var tlon = parseFloat(jsonList.listval[i].longitude);
var tlat = parseFloat(jsonList.listval[i].latitude);
//var lonlat = new OpenLayers.LonLat(tlat,tlon);
map.getView().setCenter(ol.proj.fromLonLat([tlat, tlon]));
map.getView().setZoom(5);
}
}
}
....
http://plnkr.co/edit/Rja2b1dLsJm7FDFtlUJ0?p=preview
我不能发表评论,因为我没有足够的声誉,但在你的博客中,我没有看到zoomtoist和zoomtovil函数?它们在哪个文件中?此外,您是否尝试过使用view.centerOn()[http://openlayers.org/en/v3.14.2/apidoc/ol.View.html#centerOn]?还是单独使用view.setCenter()和view.setZoom()来执行居中和缩放?
相关文章:
- jquery试图按名称获取按钮位置
- 我可以获得相对于被点击元素的确切点击位置吗
- 谷歌地图固定位置覆盖
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- UIAutomation放大图像
- 循环比赛位置算法
- es6 相当于下划线查找位置
- jQuery循环在特定位置暂停
- 引导程序:在导航栏中,显示悬停在单个位置的基于Li Link的不同内容
- 放大位置数组
- 放大后标记未放置在正确的位置
- 我想滚动放大和缩小一个图像,但也有针在该图像上保持正确的位置.jQuery
- 按openlayer 3中的位置名称放大
- 放大织物js,对象位置
- 放大单击的图像,而不考虑其他图像的位置
- 在fabricjs中放大图像后无法保留圆的位置
- 在D3散点图中,点在放大时改变位置
- 放大/缩小干扰画布绘制位置
- 当地图放大/缩小时,如何重新定位条形图位置
- 在放大时改变位置