vue-yandex-maps
Advanced tools
Comparing version 0.6.4 to 0.6.5
{ | ||
"name": "vue-yandex-maps", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "Yandex Maps component for VueJS.", | ||
@@ -5,0 +5,0 @@ "main": "vue-yandex-maps.js", |
@@ -152,2 +152,3 @@ # vue-yandex-maps | ||
| controls | Array | Array of enabled map controls. All another will be disabled. [Controls](https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/reference/control.Manager-docpage/#add-param-control) | | ||
| detailed-controls | Object | Map, where key is a name of control and value is an object of control options. | | ||
| map-type | String | Map type. Possible types: map, satellite, hybrid. Default value is map. | | ||
@@ -154,0 +155,0 @@ | scroll-zoom | Boolean | Set to false to disable zoom map on scroll page | |
@@ -107,2 +107,17 @@ export function createCallbacks(marker, placemark) { | ||
export const emitter = new EventEmitter(); | ||
const CONTROL_TYPES = [ | ||
'fullscreenControl', | ||
'geolocationControl', | ||
'routeEditor', | ||
'rulerControl', | ||
'searchControl', | ||
'trafficControl', | ||
'typeSelector', | ||
'zoomControl' | ||
]; | ||
export function controlsTypeValidator(val) { | ||
return val.filter(control => ![...CONTROL_TYPES, 'default'].includes(control)).length === 0 | ||
} | ||
@@ -35,15 +35,18 @@ import * as utils from './utils'; | ||
type: Array, | ||
default: () => ['default'] | ||
default: () => ['default'], | ||
validator(val) { | ||
return utils.controlsTypeValidator(val); | ||
} | ||
}, | ||
detailedControls: { | ||
type: Object, | ||
validator(val) { | ||
const controls = Object.keys(val); | ||
return utils.controlsTypeValidator(controls) | ||
} | ||
}, | ||
scrollZoom: { | ||
type: Boolean | ||
}, | ||
zoomControl: { | ||
type: Object, | ||
default: () => ({}) | ||
}, | ||
zoomControlPosition: { | ||
type: Object, | ||
default: () => ({}) | ||
}, | ||
zoomControl: Object, | ||
mapType: { | ||
@@ -84,2 +87,10 @@ type: String, | ||
} | ||
if (this.detailedControls) { | ||
const controls = Object.keys(this.detailedControls); | ||
controls.forEach(controlName => { | ||
this.myMap.controls.remove(controlName); | ||
const constructor = ymaps.control.storage.get(controlName); | ||
this.myMap.controls.add(new constructor(this.detailedControls[controlName])); | ||
}) | ||
} | ||
if (this.scrollZoom === false) { | ||
@@ -86,0 +97,0 @@ this.myMap.behaviors.disable('scrollZoom'); |
@@ -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,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})}); | ||
!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=["fullscreenControl","geolocationControl","routeEditor","rulerControl","searchControl","trafficControl","typeSelector","zoomControl"];function u(t){return 0===t.filter(function(t){return![].concat(l,["default"]).includes(t)}).length}var m={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"]},validator:function(t){return u(t)}},detailedControls:{type:Object,validator:function(t){return u(Object.keys(t))}},scrollZoom:{type:Boolean},zoomControl:Object,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=this,e=[],r=new ymaps.GeoObjectCollection;if(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))),this.detailedControls){Object.keys(this.detailedControls).forEach(function(e){t.myMap.controls.remove(e);var r=ymaps.control.storage.get(e);t.myMap.controls.add(new r(t.detailedControls[e]))})}!1===this.scrollZoom&&this.myMap.behaviors.disable("scrollZoom");for(var o=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})||[],s=0;s<o.length;s++){var c=o[s],l=i(c.markerType),u={hintContent:c.hintContent,iconContent:c.icon&&c.icon.content},m=c.balloon?{balloonContentHeader:c.balloon.header,balloonContentBody:c.balloon.body,balloonContentFooter:c.balloon.footer}:{};u=Object.assign(u,m);var p=c.iconLayout?{iconLayout:c.iconLayout,iconImageHref:c.iconImageHref,iconImageSize:c.iconImageSize,iconImageOffset:c.iconImageOffset}:{preset:c.icon&&"islands#"+(h=c,(h.icon.color||"blue")+(h.icon.glyph?i(h.icon.glyph):h.icon.content?"Stretchy":""))+"Icon"},f=c.markerStroke?{strokeColor:c.markerStroke.color||"0066ffff",strokeOpacity:parseFloat(c.markerStroke.opacity)>=0?parseFloat(c.markerStroke.opacity):1,strokeStyle:c.markerStroke.style,strokeWidth:parseFloat(c.markerStroke.width)>=0?parseFloat(c.markerStroke.width):1}:{},d=c.markerFill?{fill:c.markerFill.enabled||!0,fillColor:c.markerFill.color||"0066ff99",fillOpacity:parseFloat(c.markerFill.opacity)>=0?parseFloat(c.markerFill.opacity):1,fillImageHref:c.markerFill.imageHref||""}:{};p=Object.assign(p,f,d,c.balloonOptions),"Circle"===l&&(c.coords=[c.coords,c.circleRadius]);var y=new ymaps[l](c.coords,u,p);a(c,y),y.clusterName=c.clusterName,y.properties.set("markerId",c.markerId),e.push(y),r.add(y)}var h;this.placemarks&&this.placemarks.forEach(function(t){var o=new ymaps.Placemark(t.coords,t.properties||{},t.options||{});a(t,o),t.clusterName&&(o.clusterName=t.clusterName,e.push(o)),r.add(o)}),this.myMap.geoObjects.add(r),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)}}(e,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)})}},p={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})}};m.install=function(t){t.component("yandex-map",m),t.component("ymap-marker",p)};var f=m,d=p;t.yandexMap=f,t.ymapMarker=d,t.default=m,Object.defineProperty(t,"__esModule",{value:!0})}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34217
452
234