javascript - 在这里返回活动
问题描述
我正在转换为 HERE 地图 API 3.1,但无法在 HERE 中找到与 Google 和 Bing 中存在的相同功能来返回事件。
必应:返回 Microsoft.Maps.Events.addThrottledHandler (_map, 'viewchangeend', callBack, 100); 谷歌:返回 google.maps.event.addListener(_map, 'bounds_changed', callBack);
HERE 中的等价物是什么?
解决方案
如果您正在寻找 mapviewchange 或 mapviewchangeend 以下事件是信息:
在改变视口状态的过程中,每个动画步骤都会调用 Mapviewchange。在很多情况下,这种操作是过度的。例如,每次用户双击地图时,多次使用当前缩放级别更新 UI 元素是低效的。
// Displays current zoom level to the end user:
function displayZoomLevel() {...}
// A listener updates the map zoom level on each map view change
// -- this occurs more than 20 times on a double-click on the map,
// inefficient and to be avoided:
map.addEventListener('mapviewchange', function () {
var zoom = map.getZoom();
// This function is called more than 20 times on a double-click on the map!
displayZoomLevel(zoom);
});
另一方面,mapviewchangeend 仅在视口更改完成时调用一次,因此,我们建议使用此事件来更新地图视口:
/
*
Displays current zoom level to the end user
*/
function displayZoomLevel() {...}
// A listener updates the map zoom level -- it is called once when the map
// view change is complete.
map.addEventListener('mapviewchangeend', function () {
var zoom = map.getZoom();
// The function that displays the zoom level is called only once,
// after zoom level changed
displayZoomLevel(zoom);
});
mapviewchangeend 事件是 mapviewchange 的“去抖动”版本,因此,作为一项规则,使用 mapviewchangeend 更有效
推荐阅读
- scala - 究竟什么是幺半群同态?
- vb.net - 错误在代码“CheckBoxActive.Checked = Convert.ToBoolean(ds1.Tables(0).Rows(0)(3).ToString())”中显示“String is not a valid Boolean”
- debugging - Firefox 在使用开发者工具时挂起
- mongodb - mongo:查找未取代的文档
- php - PHP(取消)在比较它们时从2个动态数组中选中一个复选框
- python - 在没有更多页面 Python 后中断循环
- jquery - 如何根据下拉列表中的选择过滤页面上的数据
- java - 如何在 Libgdx java 中拖动 3d 对象?
- python - 计算没有复杂对象的 Mandelbrot 集
- c - 即使我释放了所有分配的内存,也总是发生内存泄漏