简体   繁体   中英

Switching from CDN to NPM for Google Maps JavaScript MarkerClusterer. How?

I am currently loading Google Maps JavaScript MarkerClusterer from CDN. I am trying to switch to the NPM version (to get some Typescript checking in my JavaScript files), but I do not understand how. The documentation seems to assume I do understand how. It just says I should use this line after installing the NPM version:

import { MarkerClusterer } from "@googlemaps/markerclusterer";

But Google Chrome disagrees and says

Uncaught TypeError: Failed to resolve module specifier "@googlemaps/markerclusterer". Relative references must start with either "/", "./", or "../".

What can I do to resolve this error?

you need to install

npm i @googlemaps/markerclusterer -D

https://www.npmjs.com/package/@googlemaps/markerclusterer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM