Improve code
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@fawmi/vue-google-maps",
|
"name": "@fawmi/vue-google-maps",
|
||||||
"description": "Google Map components for Vue.js 3",
|
"description": "Google Map components for Vue.js 3",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2",
|
||||||
"private": false,
|
"private": false,
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div><slot></slot></div>
|
<div>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import MarkerClusterer from 'marker-clusterer-plus'
|
import MarkerClusterer from 'marker-clusterer-plus'
|
||||||
import buildComponent from './build-component.js'
|
import buildComponent from './build-component.js'
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
maxZoom: {
|
maxZoom: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -74,13 +77,9 @@ export default buildComponent({
|
|||||||
name: 'cluster',
|
name: 'cluster',
|
||||||
ctr: () => {
|
ctr: () => {
|
||||||
if (typeof MarkerClusterer === 'undefined') {
|
if (typeof MarkerClusterer === 'undefined') {
|
||||||
/* eslint-disable no-console */
|
const errorMessage = 'MarkerClusterer is not installed!';
|
||||||
console.error(
|
console.error(errorMessage);
|
||||||
'MarkerClusterer is not installed! require() it or include it from https://cdnjs.cloudflare.com/ajax/libs/js-marker-clusterer/1.0.0/markerclusterer.js'
|
throw new Error(errorMessage)
|
||||||
)
|
|
||||||
throw new Error(
|
|
||||||
'MarkerClusterer is not installed! require() it or include it from https://cdnjs.cloudflare.com/ajax/libs/js-marker-clusterer/1.0.0/markerclusterer.js'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return MarkerClusterer
|
return MarkerClusterer
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div ref="infoWindow">
|
||||||
<div ref="infoWindow">
|
<slot></slot>
|
||||||
<slot> </slot>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="$slots.default">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
|
||||||
import buildComponent from './build-component.js'
|
import buildComponent from './build-component.js'
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@@ -71,18 +78,6 @@ const events = [
|
|||||||
'mouseout',
|
'mouseout',
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
|
||||||
* @class Marker
|
|
||||||
*
|
|
||||||
* Marker class with extra support for
|
|
||||||
*
|
|
||||||
* - Embedded info windows
|
|
||||||
* - Clustered markers
|
|
||||||
*
|
|
||||||
* Support for clustered markers is for backward-compatability
|
|
||||||
* reasons. Otherwise we should use a cluster-marker mixin or
|
|
||||||
* subclass.
|
|
||||||
*/
|
|
||||||
export default buildComponent({
|
export default buildComponent({
|
||||||
mappedProps: props,
|
mappedProps: props,
|
||||||
events,
|
events,
|
||||||
@@ -94,18 +89,6 @@ export default buildComponent({
|
|||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
render(h) {
|
|
||||||
if (!this.$slots.default || this.$slots.default.length === 0) {
|
|
||||||
return ''
|
|
||||||
} else if (this.$slots.default.length === 1) {
|
|
||||||
// So that infowindows can have a marker parent
|
|
||||||
return this.$slots.default[0]
|
|
||||||
} else {
|
|
||||||
return h('div', this.$slots.default)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
emits: ['center_changed', 'zoom_changed', 'bounds_changed'],
|
|
||||||
unmounted() {
|
unmounted() {
|
||||||
if (!this.$markerObject) {
|
if (!this.$markerObject) {
|
||||||
return
|
return
|
||||||
@@ -136,3 +119,4 @@ export default buildComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
</script>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import lazy from './utils/lazyValue'
|
import lazy from './utils/lazyValue'
|
||||||
import { loadGMapApi } from './load-google-maps'
|
import { loadGMapApi } from './load-google-maps'
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import Marker from './components/marker'
|
|
||||||
import Polyline from './components/polyline'
|
import Polyline from './components/polyline'
|
||||||
import Polygon from './components/polygon'
|
import Polygon from './components/polygon'
|
||||||
import Circle from './components/circle'
|
import Circle from './components/circle'
|
||||||
import Rectangle from './components/rectangle'
|
import Rectangle from './components/rectangle'
|
||||||
|
import Marker from './components/marker.vue'
|
||||||
import GmapCluster from './components/cluster.vue'
|
import GmapCluster from './components/cluster.vue'
|
||||||
import InfoWindow from './components/infoWindow.vue'
|
import InfoWindow from './components/infoWindow.vue'
|
||||||
import Map from './components/map.vue'
|
import Map from './components/map.vue'
|
||||||
|
|||||||
Reference in New Issue
Block a user