这里 Maps API - group.getBoundingBox 不是函数
Here Maps API - group.getBoundingBox is not a function
尝试对地图标记进行分组,然后聚焦并缩放该组。
我已遵循文档:Zooming to a Set of Markers
脚本
public viewGroupMarkers() {
// CREATE MARKERS
const toronto = new H.map.Marker({lat:43.7, lng:-79.4});
const boston = new H.map.Marker({lat:42.35805, lng:-71.0636});
const washington = new H.map.Marker({lat:38.8951, lng:-77.0366});
// CREATE GROUP
const group = new H.map.Group();
group.addObjects([toronto, boston, washington]);
// ADD GROUP TO MAP
this.map.addObject(group);
// GET VIEW BOUND GROUP
this.map.getViewModel().setLookAtData({
bounds: group.getBoundingBox()
});
}
...但是在尝试 group.getBoundingBox
时出现错误:
core.js:6479 ERROR TypeError: group.getBoundingBox is not a function
at HereMapsComponent.viewGroupMarkers (here-maps.component.ts:286:21)
at TripMapComponent.setGroupViewBounds (trip-map.component.ts:91:28)
at CardMapTripComponent.setMarkers (card-map-trip.component.ts:30:18)
at CardMapTripComponent_Template_app_trip_map_isReady_15_listener (template.html:28:11)
at executeListenerWithErrorHandling (core.js:15307:1)
at Object.wrapListenerIn_markDirtyAndPreventDefault [as next] (core.js:15345:1)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183:1)
at SafeSubscriber.next (Subscriber.js:122:1)
at Subscriber._next (Subscriber.js:72:1)
at Subscriber.next (Subscriber.js:49:1)
getBoundingBox
方法在 API 的最新 (3.1) 版本的 Group 对象中引入。
我认为您仍然加载旧版 3.0 API。
您有两个选择:
- 迁移到版本 3.1(推荐)。 migration guide 应该可以帮助您切换到 3.1 版。
- 将方法更改为
getBounds()
尝试对地图标记进行分组,然后聚焦并缩放该组。
我已遵循文档:Zooming to a Set of Markers
脚本
public viewGroupMarkers() {
// CREATE MARKERS
const toronto = new H.map.Marker({lat:43.7, lng:-79.4});
const boston = new H.map.Marker({lat:42.35805, lng:-71.0636});
const washington = new H.map.Marker({lat:38.8951, lng:-77.0366});
// CREATE GROUP
const group = new H.map.Group();
group.addObjects([toronto, boston, washington]);
// ADD GROUP TO MAP
this.map.addObject(group);
// GET VIEW BOUND GROUP
this.map.getViewModel().setLookAtData({
bounds: group.getBoundingBox()
});
}
...但是在尝试 group.getBoundingBox
时出现错误:
core.js:6479 ERROR TypeError: group.getBoundingBox is not a function
at HereMapsComponent.viewGroupMarkers (here-maps.component.ts:286:21)
at TripMapComponent.setGroupViewBounds (trip-map.component.ts:91:28)
at CardMapTripComponent.setMarkers (card-map-trip.component.ts:30:18)
at CardMapTripComponent_Template_app_trip_map_isReady_15_listener (template.html:28:11)
at executeListenerWithErrorHandling (core.js:15307:1)
at Object.wrapListenerIn_markDirtyAndPreventDefault [as next] (core.js:15345:1)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183:1)
at SafeSubscriber.next (Subscriber.js:122:1)
at Subscriber._next (Subscriber.js:72:1)
at Subscriber.next (Subscriber.js:49:1)
getBoundingBox
方法在 API 的最新 (3.1) 版本的 Group 对象中引入。
我认为您仍然加载旧版 3.0 API。
您有两个选择:
- 迁移到版本 3.1(推荐)。 migration guide 应该可以帮助您切换到 3.1 版。
- 将方法更改为
getBounds()