angular - 如何使用 Angular 中的单击按钮放大某个位置
问题描述
我想zoom
在openlayers
图书馆的某个位置,例如:Berlin
当用户点击按钮时。有人能告诉我怎么可能吗?
以下是我的代码:
app.component.html
<button id='berlin' (click)="onClick('berlin')">Zoom to Berlin</button>
app.component.ts
berlin = fromLonLat([13.388866, 52.517071]);
public onClick(city:any) {
console.log(city);
view.animate({
center: city,
duration: 2000
});
}
解决方案
var bern = ol.proj.transform([7.4458,46.95], 'EPSG:4326', 'EPSG:3857');
document.getElementById ("berlin").addEventListener ("click", berlinZoom, false);
function berlinZoom() {
var bernview = new ol.View({
center: bern,
zoom: 6
});
map.setView(bernview);
}
推荐阅读
- php - 如何在将选定的数组值发送到 mysql 之前将其内爆?(CakePHP)
- postgresql - 使用 postgres db 在 Spring Boot JPA 中自定义查询
- php - 为什么找不到“类'DI\Bridge\Slim\App'”?PHP
- javascript - 在 Paypal“添加到购物车”按钮中插入下拉菜单、文本字段和复选框
- c# - 如何使用c#.net根据日期从sql数据库中删除元素
- javascript - 如何在 javascript 事件中引用当前的 Vuex 状态和相关的 Vue 实例(this)?
- jenkins - 如何使用 github 为每个 PR 设置 Webhook 以触发 Jenkins Job
- android - 使用 LiveData 在 ViewModel 上测试功能
- ejb-3.0 - 在不同的 EJB 中获取和处理实体 Bean
- bash - Bashrc- 导出路径,不是有效标识符