diff --git a/README.MD b/README.MD index 239c624..999f849 100644 --- a/README.MD +++ b/README.MD @@ -14,13 +14,13 @@ You can use any build tool which supports `commonjs`: ```JavaScript // register globally -var yandexMap = require('vue-yandex-maps'); +var { yandexMap } = require('vue-yandex-maps'); Vue.use(yandexMap) // or for a single instance -var yandexMap = require('vue-yandex-maps'); +var { yandexMap, ymapMarker } = require('vue-yandex-maps'); new Vue({ - components: {yandexMap} + components: { yandexMap, ymapMarker } }) ``` @@ -29,13 +29,13 @@ Or in ES2015: ```JavaScript // register globally -import yandexMap from 'vue-yandex-maps' +import { yandexMap } from 'vue-yandex-maps' Vue.use(yandexMap) // or for a single instance -import yandexMap from 'vue-yandex-maps' +import { yandexMap, ymapMarker } from 'vue-yandex-maps' new Vue({ - components: {yandexMap} + components: { yandexMap, ymapMarker } }) ``` diff --git a/package.json b/package.json index 22c2b31..31cdc7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-yandex-maps", - "version": "0.1.2", + "version": "0.1.3", "description": "Yandex Maps component for VueJS.", "main": "vue-yandex-maps.js", "jsnext:main": "./src/index.js", diff --git a/src/YMap.vue b/src/YMap.vue index 8562498..28f0067 100644 --- a/src/YMap.vue +++ b/src/YMap.vue @@ -76,7 +76,7 @@ zoom: +this.zoom }); - const myMarkers = this.$slots.default.map(marker => { + const myMarkers = this.$slots.default && this.$slots.default.map(marker => { const props = marker.componentOptions && marker.componentOptions.propsData; if (!props) return; return { @@ -89,7 +89,7 @@ markerFill: props.markerFill, circleRadius: +props.circleRadius } - }).filter(marker => marker && marker.markerType); + }).filter(marker => marker && marker.markerType) || []; for (let i = 0; i < myMarkers.length; i++) { const markerType = setFirstLetterToUppercase(myMarkers[i].markerType); diff --git a/src/index.js b/src/index.js index a40547e..95f6e07 100644 --- a/src/index.js +++ b/src/index.js @@ -12,10 +12,7 @@ const install = function(Vue) { }); }; -if (window.Vue) { - window.YMapPlugin = YMapPlugin; - Vue.use(install); // eslint-disable-line -} - YMapPlugin.install = install; -export default YMapPlugin; + +export const yandexMap = YMapPlugin; +export const ymapMarker = Marker;