Skip to content

Commit

Permalink
Added attributes: behaviors, controls, map-type. Added default export.
Browse files Browse the repository at this point in the history
  • Loading branch information
PNKBizz committed Aug 19, 2017
1 parent 0648174 commit 88881c5
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 124 deletions.
16 changes: 11 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ You can use any build tool which supports `commonjs`:

```JavaScript
// register globally
var { yandexMap } = require('vue-yandex-maps');
Vue.use(yandexMap)
const YmapPlugin = require('vue-yandex-maps');
Vue.use(YmapPlugin)

// or for a single instance
var { yandexMap, ymapMarker } = require('vue-yandex-maps');
const { yandexMap, ymapMarker } = require('vue-yandex-maps');
new Vue({
components: { yandexMap, ymapMarker }
})
Expand All @@ -29,8 +29,8 @@ Or in ES2015:

```JavaScript
// register globally
import { yandexMap } from 'vue-yandex-maps'
Vue.use(yandexMap)
import YmapPlugin from 'vue-yandex-maps'
Vue.use(YmapPlugin)

// or for a single instance
import { yandexMap, ymapMarker } from 'vue-yandex-maps'
Expand Down Expand Up @@ -68,6 +68,9 @@ Type of marker in `marker-type` attribute can be:
:cluster-options="{
1: {clusterDisableClickZoom: true}
}"
:behaviors="['ruler']"
:controls="['trafficControl']"
map-type="hybrid"
>

<ymap-marker
Expand Down Expand Up @@ -110,6 +113,9 @@ Type of marker in `marker-type` attribute can be:
| coords | Array [ latitude, longtitude ] | Coordinates of map center. Required |
| zoom | Number | Zoom of map (from 0 to 19). Default value is 18. |
| cluster-options | Object | Map, where key is a name of cluster and value is an object of cluster options. [Cluster option](https://tech.yandex.ru/maps/doc/jsapi/2.0/ref/reference/Cluster-docpage/#param-options) |
| behaviors | Array | Array of enabled map behaviors. All another will be disabled. [Behaviors](https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/reference/map.behavior.Manager-docpage/#param-behaviors) |
| 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) |
| map-type | String | Map type. Possible types: map, satellite, hybrid. Default value is map. |

## Marker attributes

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-yandex-maps",
"version": "0.2.0",
"version": "0.3.0",
"description": "Yandex Maps component for VueJS.",
"main": "vue-yandex-maps.js",
"jsnext:main": "./src/index.js",
Expand Down
22 changes: 20 additions & 2 deletions src/YMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
clusterOptions: {
type: Object,
default: () => ({})
},
behaviors: {
type: Array,
default: () => ['default']
},
controls: {
type: Array,
default: () => ['default']
},
mapType: {
type: String,
default: 'map',
validator(val) {
return ['map', 'satellite', 'hybrid'].includes(val)
}
}
},
computed: {
Expand All @@ -48,7 +63,7 @@
},
watch: {
coordinates(newVal) {
this.myMap.setCenter(newVal, this.zoom)
this.myMap.setCenter && this.myMap.setCenter(newVal, this.zoom)
}
},
beforeMount() {
Expand Down Expand Up @@ -89,7 +104,10 @@
function init() {
this.myMap = new ymaps.Map(this.ymapId, {
center: this.coordinates,
zoom: +this.zoom
zoom: +this.zoom,
behaviors: this.behaviors,
controls: this.controls,
type: `yandex#${this.mapType}`
});
const myMarkers = this.$slots.default && this.$slots.default.map(marker => {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ YMapPlugin.install = install;

export const yandexMap = YMapPlugin;
export const ymapMarker = Marker;

export default YMapPlugin;
Loading

0 comments on commit 88881c5

Please sign in to comment.