Skip to content

Commit

Permalink
chore: merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed May 20, 2018
2 parents 476e571 + c52d7f9 commit 99d2940
Show file tree
Hide file tree
Showing 10 changed files with 904 additions and 529 deletions.
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
[![npm](https://img.shields.io/npm/v/vue-googlemaps.svg) ![npm](https://img.shields.io/npm/dm/vue-googlemaps.svg)](https://www.npmjs.com/package/vue-googlemaps)
[![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/)

Integrate Google Maps in your Vue application
Integrate Google Maps in your Vue application in a "Vue-way".

> This library is Work In Progress.
> More components will be available in the 1.0 release.
[Live demo](https://akryum.github.io/vue-googlemaps/)

The main objective of the library is to use Google Maps using Vue components in a way that feels natural to Vue developpers (with props, events, slots...).

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Builtin components](#builtin-components)
- [Create you own components](#create-you-own-components)
- [Quick Examples](#quick-examples)

## Installation

```
Expand All @@ -22,18 +32,89 @@ yarn add vue-googlemaps

## Usage

You need a Google API key from the [devlopper console](http://console.developers.google.com/).

```js
import 'vue-googlemaps/dist/vue-googlemaps.css'
import VueGoogleMaps from 'vue-googlemaps'

Vue.use(VueGoogleMaps, {
load: {
// Google API key
apiKey: 'your-google-api-key',
// Enable more Google Maps libraries here
libraries: ['places'],
},
})
```

## Builtin components

(Documentation is work-in-progress)

- Circle
- Geocoder
- Map
- Marker
- NearbyPlaces
- PlaceDetails
- UserPosition
- *More to come!*

## Create you own components

Here is an example of what a `Marker` component would look like:

```js
import { MapElement } from 'vue-googlemaps'

// Those Vue props will update automatically
// (Two-way binding with .sync modifier)
const boundProps = [
'animation',
'clickable',
'cursor',
'draggable',
// ...
]

// Events from Google Maps emitted as Vue events
const redirectedEvents = [
'click',
'rightclick',
'dblclick',
'drag',
// ...
]

export default {
mixins: [
// You need to use this mixin
MapElement,
],

// When Google Maps is ready
googleMapsReady () {
const options = Object.assign({}, this.$props)
options.map = this.$_map

// Create Google Maps objects
this.$_marker = new window.google.maps.Marker(options)
// Bind the Vue props
this.bindProps(this.$_marker, boundProps)
// Emit the events from Google Maps
this.redirectEvents(this.$_marker, redirectedEvents)
},

beforeDestroy () {
// Teardown
if (this.$_marker) {
this.$_marker.setMap(null)
}
},
}
```

## Quick Examples

### Map with markers
Expand Down Expand Up @@ -107,7 +188,7 @@ Vue.use(VueGoogleMaps, {

<googlemaps-nearby-places
:request="{
bounds: mapBounds
bounds: mapBounds
}"
:filter="result => !result.types.includes('locality')"
@results="results => ..."
Expand Down
22 changes: 12 additions & 10 deletions dist/vue-googlemaps.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ function createCommonjsModule(fn, module) {

var runtime = createCommonjsModule(function (module) {
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

!(function(global) {
Expand Down Expand Up @@ -1128,7 +1125,10 @@ function bindProp(_ref) {
vm.$watch(function () {
return watcher(vm[name]);
}, function (value, oldValue) {
return applier(value, oldValue, setter);
if (!identity(value, setValue)) {
applier(value, oldValue, setter);
}
setValue = value;
});

var listener = target.addListener(changeEvent, function () {
Expand Down Expand Up @@ -1677,6 +1677,8 @@ var ResizeObserver = { render: function render() {
var object = document.createElement('object');
this._resizeObject = object;
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.setAttribute('aria-hidden', 'true');
object.setAttribute('tabindex', -1);
object.onload = this.addResizeHandlers;
object.type = 'text/html';
if (isIE) {
Expand Down Expand Up @@ -1704,7 +1706,7 @@ function install(Vue) {
// Plugin
var plugin$2 = {
// eslint-disable-next-line no-undef
version: "0.4.2",
version: "0.4.4",
install: install
};

Expand Down Expand Up @@ -2240,7 +2242,7 @@ function registerComponents(Vue, prefix) {

var plugin = {
// eslint-disable-next-line no-undef
version: "0.0.6",
version: "0.1.0",
install: function install(Vue, options) {
var finalOptions = Object.assign({}, {
installComponents: true,
Expand Down Expand Up @@ -2271,5 +2273,5 @@ if (GlobalVue) {
GlobalVue.use(plugin);
}

export { Circle, Geocoder, Map, Marker, NearbyPlaces, PlaceDetails, UserPosition };
export { Circle, Geocoder, Map, Marker, NearbyPlaces, PlaceDetails, UserPosition, MapElement };
export default plugin;
2 changes: 1 addition & 1 deletion dist/vue-googlemaps.min.js

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dist/vue-googlemaps.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ function createCommonjsModule(fn, module) {

var runtime = createCommonjsModule(function (module) {
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

!(function(global) {
Expand Down Expand Up @@ -1134,7 +1131,10 @@ function bindProp(_ref) {
vm.$watch(function () {
return watcher(vm[name]);
}, function (value, oldValue) {
return applier(value, oldValue, setter);
if (!identity(value, setValue)) {
applier(value, oldValue, setter);
}
setValue = value;
});

var listener = target.addListener(changeEvent, function () {
Expand Down Expand Up @@ -1683,6 +1683,8 @@ var ResizeObserver = { render: function render() {
var object = document.createElement('object');
this._resizeObject = object;
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.setAttribute('aria-hidden', 'true');
object.setAttribute('tabindex', -1);
object.onload = this.addResizeHandlers;
object.type = 'text/html';
if (isIE) {
Expand Down Expand Up @@ -1710,7 +1712,7 @@ function install(Vue) {
// Plugin
var plugin$2 = {
// eslint-disable-next-line no-undef
version: "0.4.2",
version: "0.4.4",
install: install
};

Expand Down Expand Up @@ -2246,7 +2248,7 @@ function registerComponents(Vue, prefix) {

var plugin = {
// eslint-disable-next-line no-undef
version: "0.0.6",
version: "0.1.0",
install: function install(Vue, options) {
var finalOptions = Object.assign({}, {
installComponents: true,
Expand Down Expand Up @@ -2284,6 +2286,7 @@ exports.Marker = Marker;
exports.NearbyPlaces = NearbyPlaces;
exports.PlaceDetails = PlaceDetails;
exports.UserPosition = UserPosition;
exports.MapElement = MapElement;
exports['default'] = plugin;

Object.defineProperty(exports, '__esModule', { value: true });
Expand Down
2 changes: 1 addition & 1 deletion docs/build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/build.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-googlemaps",
"version": "0.0.6",
"version": "0.1.0",
"description": "Embed Google Maps in Vue apps",
"main": "dist/vue-googlemaps.umd.js",
"module": "dist/vue-googlemaps.esm.js",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import NearbyPlaces from './components/NearbyPlaces'
import PlaceDetails from './components/PlaceDetails'
import UserPosition from './components/UserPosition'

import MapElement from './mixins/MapElement'

export {
Circle,
Geocoder,
Expand All @@ -19,6 +21,7 @@ export {
NearbyPlaces,
PlaceDetails,
UserPosition,
MapElement,
}

function registerComponents (Vue, prefix) {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/bind-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ export function bindProp ({

vm.$watch(
() => watcher(vm[name]),
(value, oldValue) => applier(value, oldValue, setter)
(value, oldValue) => {
if (!identity(value, setValue)) {
applier(value, oldValue, setter)
}
setValue = value
}
)

const listener = target.addListener(changeEvent, () => {
Expand Down
Loading

0 comments on commit 99d2940

Please sign in to comment.