Closed
Description
I initialize map in nuxt js.
Basically, this is a try to migrating from HERE Map Tile API v2 to HERE Raster Tile API v3.
I looked though blog post on migration and there used HARP as as the engine. But using HARP causes weird error on browser console:
VM369157:141 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'layer')
at uu (eval at <anonymous> (mapsjs-core.js:72:72), <anonymous>:141:231)
at ru.createDefault (eval at <anonymous> (mapsjs-c

Here is my usage:
createHereMap(container: HTMLElement, coordinates: Array<{ lat: number; lng: number }>): Promise<H.Map> {
const isDarkMode = localStorage.getItem("mode") === "dark"
const engineType = H.Map.EngineType["HARP"]
return new Promise((resolve, reject) => {
try {
const defaultLayers = this.herePlatform!.createDefaultLayers({
engineType,
pois: true,
tileSize: devicePixelRatio > 1 ? 512 : 256,
ppi: devicePixelRatio > 1 ? 320 : 72
}) as any
const rasterTileService = this.herePlatform!.getRasterTileService({
queryParams: {
ppi: 400,
style: `explore.${isDarkMode ? "night" : "day"}`,
features: "pois:all,environmental_zones:all,congestion_zones:all",
size: "256"
}
})
const rasterTileProvider = new H.service.rasterTile.Provider(rasterTileService, {
engineType,
tileSize: 512
})
const rasterTileLayer = new H.map.layer.TileLayer(rasterTileProvider)
const map = new H.Map(container, rasterTileLayer, {
engineType,
pixelRatio: window.devicePixelRatio || 1,
center: new H.geo.Point(coordinates[0].lat, coordinates[0].lng),
zoom: 4,
padding: { top: 50, left: 50, bottom: 50, right: 50 }
})
window.addEventListener("resize", () => map.getViewPort().resize())
const mapEvents = new H.mapevents.MapEvents(map)
new H.mapevents.Behavior(mapEvents)
const ui = H.ui.UI.createDefault(map, defaultLayers)
ui.removeControl("mapsettings")
const scalebar = ui.getControl("scalebar")
ui.removeControl("scalebar")
const ms = new H.ui.MapSettingsControl({
baseLayers: [
{
label: "normal",
layer: defaultLayers.raster.normal.map
},
{
label: "satellite",
layer: defaultLayers.raster.satellite.map
}
]
})
ui.addControl("customized", ms)
ui.addControl("scalebar", scalebar!)
const zoomRectangle = new H.ui.ZoomRectangle({
alignment: H.ui.LayoutAlignment.BOTTOM_RIGHT
})
ui.addControl("rectangle", zoomRectangle)
resolve(map)
} catch (error) {
reject(error)
}
})
}
- How to migrate to raster tile v3 api?! Is my usage correct?
- If so, what would be problem with using HARP?
P.s: Removing engine type removes error.
Metadata
Metadata
Assignees
Labels
No labels