Vue AMap (vue-amap) is a component library designed for Vue 2.0 applications, providing an abstraction layer for the Gaode (Amap) Map JavaScript API. It enables declarative rendering of various map elements such as markers, polylines, polygons, circles, info windows, and more, leveraging Vue's reactivity system. The current stable version is 0.5.10. This package specifically targets the Vue 2 ecosystem and integrates with the Gaode Maps service, which is primarily used in China. The project appears to have ceased active development and maintenance, making it suitable mainly for legacy Vue 2 applications already using Gaode Maps.
npm install vue-amapVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install, initialize, and integrate vue-amap into a Vue 2 application. It shows global registration, loading the AMap API with a key and plugins, and rendering a basic map with a marker.
For new projects or migrations, consider alternative map libraries that support Vue 3 (e.g., vue-google-maps, vue-leaflet) or directly integrate the Gaode Map JavaScript API without a specific Vue 2 wrapper if Gaode Maps is a hard requirement. If using Vue 2, proceed with caution and be prepared for potential unaddressed bugs or security issues.
Obtain a valid Gaode Map API key from the official Gaode developer platform. Ensure the key is correctly passed to `VueAMap.initAMapApiLoader`.
While `v: '1.4.4'` is the default, you can try specifying a newer version in `initAMapApiLoader` (e.g., `v: '2.0'` or `v: 'latest'`) but be aware of potential compatibility issues with the `vue-amap` wrapper itself.
Ensure that your project's component naming conventions do not clash with `vue-amap`'s 'el-amap-' prefixed components. There's no built-in way to scope or selectively register components from this plugin.
Ensure `import Vue from 'vue';` is present at the top of your script if you're using a module bundler, or that Vue is loaded via a script tag before your application code in a global context.
Verify that `VueAMap.initAMapApiLoader` is called exactly once before any map components are rendered, that `YOUR_GAODE_KEY_HERE` is a valid key, and check network requests for failures to load `https://webapi.amap.com/maps?v=...`.
Ensure `Vue.use(VueAMap);` is called at the very beginning of your application setup, before any Vue instances or components that use `vue-amap` components are created.
Double-check that all data bound to `vue-amap` components (e.g., `:center`, `:position`, `:path`) is correctly initialized with arrays or objects as expected by the component, and that it's reactive data.