Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-yandex-maps

Package Overview
Dependencies
Maintainers
1
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-yandex-maps - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

.npmignore

2

package.json
{
"name": "vue-yandex-maps",
"version": "0.6.3",
"version": "0.6.4",
"description": "Yandex Maps component for VueJS.",

@@ -5,0 +5,0 @@ "main": "vue-yandex-maps.js",

@@ -7,8 +7,2 @@ import YMapPlugin from './YMap';

Vue.component('ymap-marker', Marker);
Vue.prototype.$ymapEventBus = new Vue({
data: {
ymapReady: false,
scriptIsNotAttached: true
}
});
};

@@ -15,0 +9,0 @@

@@ -1,4 +0,7 @@

import * as utils from './utils';
import { compareValues, emitter } from './utils';
export default {
data: () => ({
ymapEventBus: emitter
}),
props: {

@@ -34,5 +37,5 @@ coords: {

for (let prop in this.$props) {
this.$watch(prop, (newVal, oldVal) => utils.compareValues(newVal, oldVal, this.$ymapEventBus));
this.$watch(prop, (newVal, oldVal) => compareValues(newVal, oldVal, this.ymapEventBus));
}
}
}

@@ -78,2 +78,31 @@ export function createCallbacks(marker, placemark) {

}
class EventEmitter {
constructor() {
this.events = {};
this.ymapReady = false;
this.scriptIsNotAttached = true;
}
$on(eventName, fn) {
if (!this.events[eventName]) {
this.events[eventName] = [];
}
this.events[eventName].push(fn);
return () => {
this.events[eventName] = this.events[eventName].filter(eventFn => fn !== eventFn);
};
}
$emit(eventName, data) {
const event = this.events[eventName];
if (event) {
event.forEach(fn => fn(data));
}
}
}
export const emitter = new EventEmitter();

@@ -6,2 +6,3 @@ import * as utils from './utils';

return {
ymapEventBus: utils.emitter,
ymapId: 'yandexMap' + Math.round(Math.random() * 100000),

@@ -232,13 +233,4 @@ myMap: {}

},
beforeMount() {
if (!this.$ymapEventBus) {
const Vue = this.$root.constructor;
this.$ymapEventBus = new Vue({
data: {
ymapReady: !!window && !!window.ymaps,
scriptIsNotAttached: window && !window.ymaps
}
});
}
if (this.$ymapEventBus.scriptIsNotAttached) {
mounted() {
if (this.ymapEventBus.scriptIsNotAttached) {
const yandexMapScript = document.createElement('SCRIPT');

@@ -249,15 +241,13 @@ yandexMapScript.setAttribute('src', 'https://api-maps.yandex.ru/2.1/?lang=ru_RU');

document.body.appendChild(yandexMapScript);
this.$ymapEventBus.scriptIsNotAttached = false;
this.ymapEventBus.scriptIsNotAttached = false;
yandexMapScript.onload = () => {
this.$ymapEventBus.ymapReady = true;
this.$ymapEventBus.$emit('scriptIsLoaded');
this.ymapEventBus.ymapReady = true;
this.ymapEventBus.$emit('scriptIsLoaded');
}
}
},
mounted() {
if (this.$ymapEventBus.ymapReady) {
if (this.ymapEventBus.ymapReady) {
ymaps.ready(this.init);
} else {
this.$ymapEventBus.$on('scriptIsLoaded', () => {
this.$ymapEventBus.initMap = () => {
this.ymapEventBus.$on('scriptIsLoaded', () => {
this.ymapEventBus.initMap = () => {
this.myMap.destroy();

@@ -264,0 +254,0 @@ this.init();

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.vueYandexMaps={})}(this,function(t){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)};function o(t,r){if(t.callbacks&&"object"===e(t.callbacks))for(var o in t.callbacks)r.events.add(o,t.callbacks[o])}function a(t){return t.charAt(0).toUpperCase()+t.slice(1)}function n(t,r){var o=[];return function t(r,a){if(r===a)return!0;if(r instanceof Date&&a instanceof Date)return+r==+a;if("object"!==(void 0===r?"undefined":e(r))||"object"!==(void 0===a?"undefined":e(a)))return!1;if(function(t,e){for(var r=o.length;r--;)if(!(o[r][0]!==t&&o[r][0]!==e||o[r][1]!==e&&o[r][1]!==t))return!0;return!1}(r,a))return!0;o.push([r,a]);var n=Object.keys(r),i=n.length;if(Object.keys(a).length!==i)return!1;for(;i--;)if(!t(r[n[i]],a[n[i]]))return!1;return!0}(t,r)}var i={data:function(){return{ymapId:"yandexMap"+Math.round(1e5*Math.random()),myMap:{}}},props:{coords:{type:Array,validator:function(t){return!t.filter(function(t){return isNaN(t)}).length},required:!0},zoom:{validator:function(t){return!isNaN(t)},default:18},clusterOptions:{type:Object,default:function(){return{}}},behaviors:{type:Array,default:function(){return["default"]}},controls:{type:Array,default:function(){return["default"]}},scrollZoom:{type:Boolean},zoomControl:{type:Object,default:function(){return{}}},zoomControlPosition:{type:Object,default:function(){return{}}},mapType:{type:String,default:"map",validator:function(t){return["map","satellite","hybrid"].includes(t)}},placemarks:{type:Array,default:function(){return[]}}},computed:{coordinates:function(){return this.coords.map(function(t){return+t})}},methods:{init:function(){var t=[],e=new ymaps.GeoObjectCollection;this.myMap=new ymaps.Map(this.ymapId,{center:this.coordinates,zoom:+this.zoom,behaviors:this.behaviors,controls:this.controls,type:"yandex#"+this.mapType}),this.zoomControl&&(this.myMap.controls.remove("zoomControl"),this.myMap.controls.add(new ymaps.control.ZoomControl(this.zoomControl))),!1===this.scrollZoom&&this.myMap.behaviors.disable("scrollZoom");for(var n=this.$slots.default&&this.$slots.default.map(function(t){var e=t.componentOptions&&t.componentOptions.propsData;if(e){var r={};if(e.balloonTemplate){r={balloonContentLayout:ymaps.templateLayoutFactory.createClass(e.balloonTemplate)}}var o={markerId:e.markerId,markerType:e.markerType,coords:function t(e){return e.map(function(e){return Array.isArray(e)?t(e):+e})}(e.coords),hintContent:e.hintContent,markerFill:e.markerFill,circleRadius:+e.circleRadius,clusterName:e.clusterName,markerStroke:e.markerStroke,balloon:e.balloon,balloonOptions:r};return e.icon&&"default#image"===e.icon.layout?(o.iconLayout=e.icon.layout,o.iconImageHref=e.icon.imageHref,o.iconImageSize=e.icon.imageSize,o.iconImageOffset=e.icon.imageOffset):o.icon=e.icon,e.callbacks&&(o.callbacks=e.callbacks),e.data&&(o.data=e.data),o}}).filter(function(t){return t&&t.markerType})||[],i=0;i<n.length;i++){var s=n[i],c=a(s.markerType),l={hintContent:s.hintContent,iconContent:s.icon&&s.icon.content},u=s.balloon?{balloonContentHeader:s.balloon.header,balloonContentBody:s.balloon.body,balloonContentFooter:s.balloon.footer}:{};l=Object.assign(l,u);var m=s.iconLayout?{iconLayout:s.iconLayout,iconImageHref:s.iconImageHref,iconImageSize:s.iconImageSize,iconImageOffset:s.iconImageOffset}:{preset:s.icon&&"islands#"+(f=s,(f.icon.color||"blue")+(f.icon.glyph?a(f.icon.glyph):f.icon.content?"Stretchy":""))+"Icon"},p=s.markerStroke?{strokeColor:s.markerStroke.color||"0066ffff",strokeOpacity:parseFloat(s.markerStroke.opacity)>=0?parseFloat(s.markerStroke.opacity):1,strokeStyle:s.markerStroke.style,strokeWidth:parseFloat(s.markerStroke.width)>=0?parseFloat(s.markerStroke.width):1}:{},d=s.markerFill?{fill:s.markerFill.enabled||!0,fillColor:s.markerFill.color||"0066ff99",fillOpacity:parseFloat(s.markerFill.opacity)>=0?parseFloat(s.markerFill.opacity):1,fillImageHref:s.markerFill.imageHref||""}:{};m=Object.assign(m,p,d,s.balloonOptions),"Circle"===c&&(s.coords=[s.coords,s.circleRadius]);var y=new ymaps[c](s.coords,l,m);o(s,y),y.clusterName=s.clusterName,y.properties.set("markerId",s.markerId),t.push(y),e.add(y)}var f;this.placemarks&&this.placemarks.forEach(function(r){var a=new ymaps.Placemark(r.coords,r.properties||{},r.options||{});o(r,a),r.clusterName&&(a.clusterName=r.clusterName,t.push(a)),e.add(a)}),this.myMap.geoObjects.add(e),function(t,e,o){var a={},n=!0,i=!1,s=void 0;try{for(var c,l=t[Symbol.iterator]();!(n=(c=l.next()).done);n=!0){var u=c.value;u.clusterName&&(a[u.clusterName]=a[u.clusterName]?[].concat(r(a[u.clusterName]),[u]):[u])}}catch(t){i=!0,s=t}finally{try{!n&&l.return&&l.return()}finally{if(i)throw s}}for(var m in a){var p=e[m]||{},d=new ymaps.Clusterer(p);d.add(a[m]),o.geoObjects.add(d)}}(t,this.clusterOptions,this.myMap),this.$emit("map-was-initialized",this.myMap)}},watch:{coordinates:function(t){this.myMap.setCenter&&this.myMap.setCenter(t,this.zoom)},placemarks:function(t,e){window.ymaps&&(this.myMap.destroy&&this.myMap.destroy(),this.init())}},render:function(t){return t("section",{class:"ymap-container"},[t("div",{attrs:{id:this.ymapId,class:"ymap-body"}}),this.$slots.default])},beforeMount:function(){var t=this;if(!this.$ymapEventBus){var e=this.$root.constructor;this.$ymapEventBus=new e({data:{ymapReady:!!window&&!!window.ymaps,scriptIsNotAttached:window&&!window.ymaps}})}if(this.$ymapEventBus.scriptIsNotAttached){var r=document.createElement("SCRIPT");r.setAttribute("src","https://api-maps.yandex.ru/2.1/?lang=ru_RU"),r.setAttribute("async",""),r.setAttribute("defer",""),document.body.appendChild(r),this.$ymapEventBus.scriptIsNotAttached=!1,r.onload=function(){t.$ymapEventBus.ymapReady=!0,t.$ymapEventBus.$emit("scriptIsLoaded")}}},mounted:function(){var t=this;this.$ymapEventBus.ymapReady?ymaps.ready(this.init):this.$ymapEventBus.$on("scriptIsLoaded",function(){t.$ymapEventBus.initMap=function(){t.myMap.destroy(),t.init()},ymaps.ready(t.init)})}},s={props:{coords:{type:Array,required:!0},hintContent:String,icon:Object,balloon:Object,markerType:{type:String,required:!0},markerFill:Object,markerStroke:Object,clusterName:String,circleRadius:{validator:function(t){return!isNaN(t)},default:1e3},callbacks:Object,data:Object,balloonTemplate:String,markerId:[String,Number]},render:function(){},mounted:function(){var t=this;for(var e in this.$props)this.$watch(e,function(e,r){return o=e,a=r,i=t.$ymapEventBus,void(n(o,a)||(i.rerender&&clearTimeout(i.rerender),i.rerender=setTimeout(function(){return i.initMap&&i.initMap()},10)));var o,a,i})}};i.install=function(t){t.component("yandex-map",i),t.component("ymap-marker",s),t.prototype.$ymapEventBus=new t({data:{ymapReady:!1,scriptIsNotAttached:!0}})};var c=i,l=s;t.yandexMap=c,t.ymapMarker=l,t.default=i,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.vueYandexMaps={})}(this,function(t){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}}(),n=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)};function a(t,r){if(t.callbacks&&"object"===e(t.callbacks))for(var o in t.callbacks)r.events.add(o,t.callbacks[o])}function i(t){return t.charAt(0).toUpperCase()+t.slice(1)}function s(t,r){var o=[];return function t(r,n){if(r===n)return!0;if(r instanceof Date&&n instanceof Date)return+r==+n;if("object"!==(void 0===r?"undefined":e(r))||"object"!==(void 0===n?"undefined":e(n)))return!1;if(function(t,e){for(var r=o.length;r--;)if(!(o[r][0]!==t&&o[r][0]!==e||o[r][1]!==e&&o[r][1]!==t))return!0;return!1}(r,n))return!0;o.push([r,n]);var a=Object.keys(r),i=a.length;if(Object.keys(n).length!==i)return!1;for(;i--;)if(!t(r[a[i]],n[a[i]]))return!1;return!0}(t,r)}var c=new(function(){function t(){r(this,t),this.events={},this.ymapReady=!1,this.scriptIsNotAttached=!0}return o(t,[{key:"$on",value:function(t,e){var r=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(e),function(){r.events[t]=r.events[t].filter(function(t){return e!==t})}}},{key:"$emit",value:function(t,e){var r=this.events[t];r&&r.forEach(function(t){return t(e)})}}]),t}()),l={data:function(){return{ymapEventBus:c,ymapId:"yandexMap"+Math.round(1e5*Math.random()),myMap:{}}},props:{coords:{type:Array,validator:function(t){return!t.filter(function(t){return isNaN(t)}).length},required:!0},zoom:{validator:function(t){return!isNaN(t)},default:18},clusterOptions:{type:Object,default:function(){return{}}},behaviors:{type:Array,default:function(){return["default"]}},controls:{type:Array,default:function(){return["default"]}},scrollZoom:{type:Boolean},zoomControl:{type:Object,default:function(){return{}}},zoomControlPosition:{type:Object,default:function(){return{}}},mapType:{type:String,default:"map",validator:function(t){return["map","satellite","hybrid"].includes(t)}},placemarks:{type:Array,default:function(){return[]}}},computed:{coordinates:function(){return this.coords.map(function(t){return+t})}},methods:{init:function(){var t=[],e=new ymaps.GeoObjectCollection;this.myMap=new ymaps.Map(this.ymapId,{center:this.coordinates,zoom:+this.zoom,behaviors:this.behaviors,controls:this.controls,type:"yandex#"+this.mapType}),this.zoomControl&&(this.myMap.controls.remove("zoomControl"),this.myMap.controls.add(new ymaps.control.ZoomControl(this.zoomControl))),!1===this.scrollZoom&&this.myMap.behaviors.disable("scrollZoom");for(var r=this.$slots.default&&this.$slots.default.map(function(t){var e=t.componentOptions&&t.componentOptions.propsData;if(e){var r={};if(e.balloonTemplate){r={balloonContentLayout:ymaps.templateLayoutFactory.createClass(e.balloonTemplate)}}var o={markerId:e.markerId,markerType:e.markerType,coords:function t(e){return e.map(function(e){return Array.isArray(e)?t(e):+e})}(e.coords),hintContent:e.hintContent,markerFill:e.markerFill,circleRadius:+e.circleRadius,clusterName:e.clusterName,markerStroke:e.markerStroke,balloon:e.balloon,balloonOptions:r};return e.icon&&"default#image"===e.icon.layout?(o.iconLayout=e.icon.layout,o.iconImageHref=e.icon.imageHref,o.iconImageSize=e.icon.imageSize,o.iconImageOffset=e.icon.imageOffset):o.icon=e.icon,e.callbacks&&(o.callbacks=e.callbacks),e.data&&(o.data=e.data),o}}).filter(function(t){return t&&t.markerType})||[],o=0;o<r.length;o++){var s=r[o],c=i(s.markerType),l={hintContent:s.hintContent,iconContent:s.icon&&s.icon.content},u=s.balloon?{balloonContentHeader:s.balloon.header,balloonContentBody:s.balloon.body,balloonContentFooter:s.balloon.footer}:{};l=Object.assign(l,u);var m=s.iconLayout?{iconLayout:s.iconLayout,iconImageHref:s.iconImageHref,iconImageSize:s.iconImageSize,iconImageOffset:s.iconImageOffset}:{preset:s.icon&&"islands#"+(y=s,(y.icon.color||"blue")+(y.icon.glyph?i(y.icon.glyph):y.icon.content?"Stretchy":""))+"Icon"},p=s.markerStroke?{strokeColor:s.markerStroke.color||"0066ffff",strokeOpacity:parseFloat(s.markerStroke.opacity)>=0?parseFloat(s.markerStroke.opacity):1,strokeStyle:s.markerStroke.style,strokeWidth:parseFloat(s.markerStroke.width)>=0?parseFloat(s.markerStroke.width):1}:{},f=s.markerFill?{fill:s.markerFill.enabled||!0,fillColor:s.markerFill.color||"0066ff99",fillOpacity:parseFloat(s.markerFill.opacity)>=0?parseFloat(s.markerFill.opacity):1,fillImageHref:s.markerFill.imageHref||""}:{};m=Object.assign(m,p,f,s.balloonOptions),"Circle"===c&&(s.coords=[s.coords,s.circleRadius]);var d=new ymaps[c](s.coords,l,m);a(s,d),d.clusterName=s.clusterName,d.properties.set("markerId",s.markerId),t.push(d),e.add(d)}var y;this.placemarks&&this.placemarks.forEach(function(r){var o=new ymaps.Placemark(r.coords,r.properties||{},r.options||{});a(r,o),r.clusterName&&(o.clusterName=r.clusterName,t.push(o)),e.add(o)}),this.myMap.geoObjects.add(e),function(t,e,r){var o={},a=!0,i=!1,s=void 0;try{for(var c,l=t[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var u=c.value;u.clusterName&&(o[u.clusterName]=o[u.clusterName]?[].concat(n(o[u.clusterName]),[u]):[u])}}catch(t){i=!0,s=t}finally{try{!a&&l.return&&l.return()}finally{if(i)throw s}}for(var m in o){var p=e[m]||{},f=new ymaps.Clusterer(p);f.add(o[m]),r.geoObjects.add(f)}}(t,this.clusterOptions,this.myMap),this.$emit("map-was-initialized",this.myMap)}},watch:{coordinates:function(t){this.myMap.setCenter&&this.myMap.setCenter(t,this.zoom)},placemarks:function(t,e){window.ymaps&&(this.myMap.destroy&&this.myMap.destroy(),this.init())}},render:function(t){return t("section",{class:"ymap-container"},[t("div",{attrs:{id:this.ymapId,class:"ymap-body"}}),this.$slots.default])},mounted:function(){var t=this;if(this.ymapEventBus.scriptIsNotAttached){var e=document.createElement("SCRIPT");e.setAttribute("src","https://api-maps.yandex.ru/2.1/?lang=ru_RU"),e.setAttribute("async",""),e.setAttribute("defer",""),document.body.appendChild(e),this.ymapEventBus.scriptIsNotAttached=!1,e.onload=function(){t.ymapEventBus.ymapReady=!0,t.ymapEventBus.$emit("scriptIsLoaded")}}this.ymapEventBus.ymapReady?ymaps.ready(this.init):this.ymapEventBus.$on("scriptIsLoaded",function(){t.ymapEventBus.initMap=function(){t.myMap.destroy(),t.init()},ymaps.ready(t.init)})}},u={data:function(){return{ymapEventBus:c}},props:{coords:{type:Array,required:!0},hintContent:String,icon:Object,balloon:Object,markerType:{type:String,required:!0},markerFill:Object,markerStroke:Object,clusterName:String,circleRadius:{validator:function(t){return!isNaN(t)},default:1e3},callbacks:Object,data:Object,balloonTemplate:String,markerId:[String,Number]},render:function(){},mounted:function(){var t=this;for(var e in this.$props)this.$watch(e,function(e,r){return o=e,n=r,a=t.ymapEventBus,void(s(o,n)||(a.rerender&&clearTimeout(a.rerender),a.rerender=setTimeout(function(){return a.initMap&&a.initMap()},10)));var o,n,a})}};l.install=function(t){t.component("yandex-map",l),t.component("ymap-marker",u)};var m=l,p=u;t.yandexMap=m,t.ymapMarker=p,t.default=l,Object.defineProperty(t,"__esModule",{value:!0})});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc