here map官方没有npm,但是有JavaScript版本api。想要集成next.js,就需要get-js这个npm,加载here map基本代码。
npm install get-js --save
import getJS from "get-js";
function map({ list }) {
useEffect(() => {
getJS(['https://js.cit.api.here.com/v3/3.0/mapsjs-core.js',
'https://js.cit.api.here.com/v3/3.0/mapsjs-service.js',
"https://js.cit.api.here.com/v3/3.0/mapsjs-ui.js",
"https://js.cit.api.here.com/v3/3.0/mapsjs-mapevents.js",
"https://js.cit.api.here.com/v3/3.0/mapsjs-clustering.js"])
.then(function (e) {
console.log('do something now', e);
console.log("h11", H);
//这里写调用api接口
})
.catch(function (e) {
console.log('error', e);
});
}, [])
return (
<>
<div id="map" style={{ width: "600px", height: "600px" }}></div>
</>
);
}
export default map;