const initMap = React.useCallback(defaultLayers => {
let lat = -6;
let lng = 100;
let zoom = 20;
areaMapRef.current = new window.H.Map(
mapContainerRef.current,
defaultLayers.vector.normal.map,
{
zoom,
center: { lng, lat }
}
);
window.addEventListener("resize", areaMapRef.current.getViewPort().resize);
behaviourRef.current = new window.H.mapevents.Behavior(
new window.H.mapevents.MapEvents(areaMapRef.current)
);
uiRef.current = window.H.ui.UI.createDefault(
areaMapRef.current,
defaultLayers
);
}, []);
React.useEffect(() => {
const platform = new window.H.service.Platform({
apikey: "MYAPIKEY"
});
const defaultLayers = platform.createDefaultLayers();
initMap(defaultLayers);},
[initMap]);