当位置(纬度/经度)发生变化时,HereMaps DomIcon 更新缓慢,重新渲染
Slow updating HereMaps DomIcon when location (lat / long) changes, re-render
使用 renderToStaticMarkup
将 html 渲染为 HereMaps 中的 DomIcon
。当没有那么多标记和更新时,这很有效而且很快。但是,100 个标记频繁更新和重新呈现导致页面打开缓慢。它甚至会减慢地图渲染速度。
我调查了 best practices around re-using a DomIcon. I've -- 但不确定更新如何进行。聚类是在这里走得更远的唯一途径吗?想知道是否还有其他最佳性能实践
聚类解决了潜在的性能问题,但是 H.map.Group 用于将标记关联在一起,并且 group.getBounds() 方法用于查找包含所有组内容的最小边界框。然后可以更新 map.viewBounds()。
function addMarkersAndSetViewBounds() {
// create map objects
var toronto = new H.map.Marker({lat:43.7, lng:-79.4}),
boston = new H.map.Marker({lat:42.35805, lng:-71.0636}),
washington = new H.map.Marker({lat:38.8951, lng:-77.0366}),
group = new H.map.Group();
// add markers to the group
group.addObjects([toronto, boston, washington]);
map.addObject(group);
// get geo bounding box for the group and set it to the map
map.getViewModel().setLookAtData({
bounds: group.getBoundingBox()
});
}
forEachDataPoint(回调)
此方法为给定集群中的每个数据点调用指定的回调,可用于更新数据点。
A clustering algorithm groups data points by collapsing two or more
points positioned close to one another on the screen into a single
cluster point. All other (not collapsed) points are still visible on
map as noise points.
如果这确实适合用例,请选择集群。它有助于提升性能问题。有关详细信息,请参阅:
developer.here.com/documentation/maps/topics/clustering.html
使用 renderToStaticMarkup
将 html 渲染为 HereMaps 中的 DomIcon
。当没有那么多标记和更新时,这很有效而且很快。但是,100 个标记频繁更新和重新呈现导致页面打开缓慢。它甚至会减慢地图渲染速度。
我调查了 best practices around re-using a DomIcon. I've
聚类解决了潜在的性能问题,但是 H.map.Group 用于将标记关联在一起,并且 group.getBounds() 方法用于查找包含所有组内容的最小边界框。然后可以更新 map.viewBounds()。
function addMarkersAndSetViewBounds() {
// create map objects
var toronto = new H.map.Marker({lat:43.7, lng:-79.4}),
boston = new H.map.Marker({lat:42.35805, lng:-71.0636}),
washington = new H.map.Marker({lat:38.8951, lng:-77.0366}),
group = new H.map.Group();
// add markers to the group
group.addObjects([toronto, boston, washington]);
map.addObject(group);
// get geo bounding box for the group and set it to the map
map.getViewModel().setLookAtData({
bounds: group.getBoundingBox()
});
}
forEachDataPoint(回调)
此方法为给定集群中的每个数据点调用指定的回调,可用于更新数据点。
A clustering algorithm groups data points by collapsing two or more points positioned close to one another on the screen into a single cluster point. All other (not collapsed) points are still visible on map as noise points.
如果这确实适合用例,请选择集群。它有助于提升性能问题。有关详细信息,请参阅: developer.here.com/documentation/maps/topics/clustering.html