Git Product home page Git Product logo

vue-google-maps's Introduction

CONTRIBUTORS NEEDED!

It's been increasingly difficult for me to make time to maintain this project. My projects at work have also gradually migrated away from Google Maps (but still on Vue -- Vue's awesome!), so there's less and less incentive to maintain.

If you have time to contribute to a rather frequently used library, feel free to make a PR! For more background, please refer to this issue.

What's urgently needed are:

  1. Better automated tests
  2. Better integration tests with the popular frameworks, especially Nuxt and Vue template
  3. Better documentation (examples, recommendations)

The above three will go a long way to keeping the project maintainable and contributable, and will address many of the open issues.

vue-google-maps

Build Status

Vue-2 port of vue-google-maps

This is the Vue 2.x port of vue-google-maps!

Attention!

This great package doesn't release the last features added to it for different reasons, is because it that some developers land a new package with the last features added to it.

If you want to use the last features in this package you can use gmap-vue, it is a fork of this repository and has all new fixes and features added to it.

This new package has new documentation with live examples that can you test with your own gmap key. You can visit it following this link gmap-vue docs.

Installation

With npm (Recommended)

npm install vue2-google-maps

Manually

Just download dist/vue-google-maps.js file and include it from your HTML.

Be aware that if you use this method, you cannot use TitleCase for your components and your attributes. That is, instead of writing <GmapMap>, you need to write <gmap-map>.

Example (Source code).

Basic usage / Documentation

Get an API key from Google

Generating an Google Maps API key.

Quickstart (Webpack, Nuxt):

If you are using Webpack and Vue file components, just add the following to your code!

<GmapMap
  :center="{lat:10, lng:10}"
  :zoom="7"
  map-type-id="terrain"
  style="width: 500px; height: 300px"
>
  <GmapMarker
    :key="index"
    v-for="(m, index) in markers"
    :position="m.position"
    :clickable="true"
    :draggable="true"
    @click="center=m.position"
  />
</GmapMap>

In your main.js or inside a Nuxt plugin:

import Vue from 'vue'
import * as VueGoogleMaps from 'vue2-google-maps'

Vue.use(VueGoogleMaps, {
  load: {
    key: 'YOUR_API_TOKEN',
    libraries: 'places', // This is required if you use the Autocomplete plugin
    // OR: libraries: 'places,drawing'
    // OR: libraries: 'places,drawing,visualization'
    // (as you require)

    //// If you want to set the version, you can do so:
    // v: '3.26',
  },

  //// If you intend to programmatically custom event listener code
  //// (e.g. `this.$refs.gmap.$on('zoom_changed', someFunc)`)
  //// instead of going through Vue templates (e.g. `<GmapMap @zoom_changed="someFunc">`)
  //// you might need to turn this on.
  // autobindAllEvents: false,

  //// If you want to manually install components, e.g.
  //// import {GmapMarker} from 'vue2-google-maps/src/components/marker'
  //// Vue.component('GmapMarker', GmapMarker)
  //// then set installComponents to 'false'.
  //// If you want to automatically install all the components this property must be set to 'true':
  installComponents: true
})

If you need to gain access to the Map instance (e.g. to call panToBounds, panTo):

<template>
<GmapMap ref="mapRef" ...>
</GmapMap>
</template>
<script>
export default {
  mounted () {
    // At this point, the child GmapMap has been mounted, but
    // its map has not been initialized.
    // Therefore we need to write mapRef.$mapPromise.then(() => ...)

    this.$refs.mapRef.$mapPromise.then((map) => {
      map.panTo({lat: 1.38, lng: 103.80})
    })
  }
}

If you need to gain access to the google object:

<template>
  <GmapMarker ref="myMarker"
    :position="google && new google.maps.LatLng(1.38, 103.8)" />
</template>
<script>
import {gmapApi} from 'vue2-google-maps'

export default {
  computed: {
    google: gmapApi
  }
}
</script>

Control the options of the map with the options property:

Example of MapOptions:

<GmapMap
 :options="{
   zoomControl: true,
   mapTypeControl: false,
   scaleControl: false,
   streetViewControl: false,
   rotateControl: false,
   fullscreenControl: true,
   disableDefaultUI: false
 }"
>
</GmapMap>

Add region and language localization:

Example for Localization:

Vue.use(VueGoogleMaps, {
  load: {
    region: 'VI',
    language: 'vi',
  },
})

Nuxt.js config

For Nuxt.js projects, please import VueGoogleMaps in the following manner:

import * as VueGoogleMaps from '~/node_modules/vue2-google-maps'

Add the following to your nuxt.config.js's build.extend():

transpile: [/^vue2-google-maps($|\/)/]

Officially supported components:

The list of officially support components are:

  • Rectangle, Circle
  • Polygon, Polyline
  • KML Layer
  • Marker
  • InfoWindow
  • Autocomplete
  • Cluster* (via marker-clusterer-plus)

You can find examples of this on the website. Auto-generated API documentation for these components are here.

For Cluster, you must import the class specifically, e.g.

import GmapCluster from 'vue2-google-maps/dist/components/cluster' // replace src with dist if you have Babel issues

Vue.component('GmapCluster', GmapCluster)

Inconvenient, but this means all other users don't have to bundle the marker clusterer package in their source code.

Autocomplete component

The autocomplete supports custom text field via scoped slot

          <gmap-autocomplete class="introInput" >
                    <template v-slot:input="slotProps">
                        <v-text-field outlined
                                      prepend-inner-icon="place"
                                      placeholder="Location Of Event"
                                      ref="input"
                                      v-on:listeners="slotProps.listeners"
                                      v-on:attrs="slotProps.attrs">
                        </v-text-field>
                    </template>
        </gmap-autocomplete>

The ref on the element must be called input, if the element is a vue component then it must have a child ref called input (like in vuetify text-field) or speciy a custom name via childRefName property (only works one level deep into a component).

The v-on:listeners is rquired, v-on:attrs may or may not be required depending on your implementation.

This requires vue 2.6 or higher for the new slot support.

NOTE: The official NPM package does not support this until the NPM package is updated, you can use this alternate temporary one or build your own version from source.

https://www.npmjs.com/package/vue2-google-maps-withscopedautocomp

Adding your own components

It should be relatively easy to add your own components (e.g. Heatmap, GroundOverlay). please refer to the source code for MapElementFactory.

Example for DirectionsRenderer:

// DirectionsRenderer.js
import {MapElementFactory} from 'vue2-google-maps'

export default MapElementFactory({
  name: 'directionsRenderer',
  ctr: () => google.maps.DirectionsRenderer,
  //// The following is optional, but necessary if the constructor takes multiple arguments
  //// e.g. for GroundOverlay
  // ctrArgs: (options, otherProps) => [options],
  events: ['directions_changed'],

  // Mapped Props will automatically set up
  //   this.$watch('propertyName', (v) => instance.setPropertyName(v))
  //
  // If you specify `twoWay`, then it also sets up:
  //   google.maps.event.addListener(instance, 'propertyName_changed', () => {
  //     this.$emit('propertyName_changed', instance.getPropertyName())
  //   })
  //
  // If you specify `noBind`, then neither will be set up. You should manually
  // create your watchers in `afterCreate()`.
  mappedProps: {
    routeIndex: { type: Number },
    options: { type: Object },
    panel: { },
    directions: { type: Object },
    //// If you have a property that comes with a `_changed` event,
    //// you can specify `twoWay` to automatically bind the event, e.g. Map's `zoom`:
    // zoom: {type: Number, twoWay: true}
  },
  // Any other properties you want to bind. Note: Must be in Object notation
  props: {},
  // Actions you want to perform before creating the object instance using the
  // provided constructor (for example, you can modify the `options` object).
  // If you return a promise, execution will suspend until the promise resolves
  beforeCreate (options) {},
  // Actions to perform after creating the object instance.
  afterCreate (directionsRendererInstance) {},
})

Thereafter, it's easy to use the newly-minted component!

<template>
  <GmapMap :zoom="..." :center="...">
    <DirectionsRenderer />
  </GmapMap>
</template>
<script>
import DirectionsRenderer from './DirectionsRenderer.js'

export default {
  components: {DirectionsRenderer}
}
</script>

Testing

More automated tests should be written to help new contributors.

Meanwhile, please test your changes against the suite of examples.

Improvements to the tests are welcome :)

vue-google-maps's People

Contributors

atinux avatar diegoazh avatar goocci avatar guillaumeleclerc avatar harrjdk avatar jeancaffou avatar jjjrmy avatar jlaswell avatar josegoncalves avatar joshrosenhanst avatar mattgoldwater avatar michaelhue avatar monsieurmechant avatar mrkriegler avatar noevidenz avatar plarsson avatar richard1984 avatar rokkie avatar shayneo avatar smartpierre avatar smhutch avatar stevendesu avatar thgh avatar thijsvdanker avatar trendytim avatar valeriosillari avatar varna avatar woodhull avatar xkjyeah avatar yyx990803 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-google-maps's Issues

Cannot get $mapObject

this.$refs.gmap.mapCreated.then((gmapObject) => {
    console.log(gmapObject)
})

I want to get the $mapObject and running the above code in mounted() { } but i wont work. Also i want to getCenter() or getBounds()
this.$refs.gmap.$mapObject.getCenter() - I have tried for 2 hourse, i cant get the center or even bounds in mehtods. Events like bounds_changed and center_changed working. But i need mapObject to get or set center. Pls help!

Customizing markers with custom icon

I'm trying to create markers with custom icons, and as my icons are not so standard I need to specify the size, scaledSize, anchor and origin properties as well.

All of those require the use of new google.maps.Size or new google.maps.Point which are not available as the component is isolated from the actual script being loaded on runtime.

Is there any way you could expose the additional properties for the icon or include those additional classes in vue-google-maps as well?

Thanks a lot!

Using with other Google Maps library

I'm trying to use js-rich-marker along with this component, but cannot fix this error Uncaught ReferenceError: google is not defined.

This library requires google.maps.OverlayView, which is not avaliable.

Is there any way to fix this issues?

Many thanks.

Autocomplete

Hi, big thanks for your work! I was wondering if it's possible to use Google Places Autocomplete from your plugin?

How to make a map unclickable

I'm searching in the repo but I can find this.

I don't want the map to scrollable, clickable or draggable with a fixed center and zoom.

How I can achieve this?

Problem with Vue.js 2.1.8

Hi!

I just tried to use the plugin with Vue.js v. 2.1.8, but it doesn't work :(

I get an error:

createElm โ€” vue.js:4062 TypeError: undefined is not an object (evaluating 'vnode.isRootInsert = !nested')

Vue.use() Error

Hello, I get this plugin.apply is not a function(โ€ฆ) error on this part of your code:

  Vue.use(VueGoogleMaps, {
    installComponents: true,
    load: {
      key: 'API_KEY',
      v: '3.26'
    }
  })

I think the problem is my webpack config, I use the standard webpack-config from vue-cli.

Error: VueComponent component must be used within a <Map>

Getting the following error when using markers inside the map.

[Vue warn]: Error in created hook:
(found in )
Error: VueComponent component must be used within a

Using vue-loader & vue (latest)

main.js

import * as VueGoogleMaps from 'vue2-google-maps';
Vue.component( 'google-map', Vue.extend(Map) );
Vue.component( 'google-marker', Vue.extend(Marker) );

component

<google-map :center="{lat:1.38, lng:103.8}" :zoom="12" style="width: 100%; padding-bottom: 60%; position: absolute; left:0; top:0;border-radius:.75em;border:1px solid #ccc">
  <google-marker :position="{lat:1.38, lng:103.8}">
  </google-marker>
</google-map>

Any ideas?

I've tried with installComponents: true, installComponents: false, Vue.component( 'google-map', Vue.extend(Map) );, and Vue.component( 'google-map', Map );

can't open windowInfo

First: Thanks a lot for the Vue2 version :)

i can't open the infoWindow if i click on the marker, do you know how to fix it ?

repro
link

Create a marker with right click, close it, and try to reopen.

Meteor integration

Hello,

I'm trying to get vue2-google-maps to work in a Meteor project.

I have tried a lot of different ways to import the library and use it, but the dependencies are somehow not being resolved:


=> App running at: http://localhost:3000/

Unable to resolve some modules:

  "_" in <PATH>/vue2-google-maps.js (web.browser)
  "MarkerClusterer" in <PATH>/vue2-google-maps.js (web.browser)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save _ MarkerClusterer

I've tried to declare a couple of global variables using these names ('_' and 'MarkerClusterer') according to Meteor documentation, but can't make it work.

Also on the browser I am getting this:

Uncaught Error: Cannot find module '_'
    at require (http://localhost:3000/packages/modules-runtime.js?hash=637cb12b6fd3acf3ffbfcf0f2ee1cf3988a7f1fe:119:19)
    at n.(anonymous function).exports (http://localhost:3000/app/app.js?hash=c9e972a581f8948ecc022247bf873501cd0703a5:411:180)
    at meteorInstall.imports.vue2-google-maps.js (http://localhost:3000/app/app.js?hash=c9e972a581f8948ecc022247bf873501cd0703a5:412:2)
    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=637cb12b6fd3acf3ffbfcf0f2ee1cf3988a7f1fe:191:9)
    at Module.require (http://localhost:3000/packages/modules-runtime.js?hash=637cb12b6fd3acf3ffbfcf0f2ee1cf3988a7f1fe:116:16)
    at Module.Mp.import (http://localhost:3000/packages/modules.js?hash=005111aa41bfbfe5e05b60f94732b2ea9f196ba4:313:16)
    at meteorInstall.client.main.js (http://localhost:3000/app/app.js?hash=c9e972a581f8948ecc022247bf873501cd0703a5:21:429)
    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=637cb12b6fd3acf3ffbfcf0f2ee1cf3988a7f1fe:191:9)
    at require (http://localhost:3000/packages/modules-runtime.js?hash=637cb12b6fd3acf3ffbfcf0f2ee1cf3988a7f1fe:116:16)
    at http://localhost:3000/app/app.js?hash=c9e972a581f8948ecc022247bf873501cd0703a5:2511:1

I've received some help but still can't fix my issue: Vue + Meteor integration

Any ideas?

Unable to do panBy() method

Hi, sorry if I am overseeing something here. I have been trying to move my map using the panBy method, but cannot get it to work.

I have followed the advice on the vue-google-maps wiki "You can do it either by calling them on the map vue instance or sending an event g-methodName", but am unsure how to do this. Any advice would be appreciated.

bounds_changed not triggered when the map initialized

Hi,

I found the bounds_changed event is not triggered when the map is initialized. After taking a look into the code in mapImpl.js, I see the following lines:

      // manually trigger center and zoom
      this.$mapObject.addListener('center_changed', () => {
        this.$emit('center_changed', this.$mapObject.getCenter())
        this.$emit('bounds_changed', this.$mapObject.getBounds())
      })
      this.$mapObject.addListener('zoom_changed', () => {
        this.$emit('zoom_changed', this.$mapObject.getZoom())
        this.$emit('bounds_changed', this.$mapObject.getBounds())
      })

I'm not sure why center_changed isn't triggered, but anyway changing that code to below seems to resolve the issue (it works well also on center_changed and zoom_changed).

      this.$mapObject.addListener('center_changed', () => {
        this.$emit('center_changed', this.$mapObject.getCenter())
      })
      this.$mapObject.addListener('zoom_changed', () => {
        this.$emit('zoom_changed', this.$mapObject.getZoom())
      })
      this.$mapObject.addListener('bounds_changed', () => {
        this.$emit('bounds_changed', this.$mapObject.getBounds())
      })

Could you please review it? Thanks!

missing dependency when "npm install"

screen shot 2016-12-20 at 9 59 23 am

This is my first fresh install of this package and I encountered the above issue.
(Since this is my first installation, I am sure that the missing package was not take from cache.)

Thank for any hints

Marker Component: Right-hand side of 'instanceof' is not an object

Hi.

Marker Component is broken, this is my html

<body>
  <div id="root">
    <div style="width: 100%; height: 500px">
      <google-map
        :center="center"
        :zoom="7"
      >
        <google-marker
          v-for="m in markers"
          :position="m.position"
          :clickable="true"
          :draggable="true"
          @click="center=m.position"
        ></google-marker>
      </google-map>
    </div>
  </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue-google-maps.js"></script>

<script>

Vue.use(VueGoogleMap, {
  load: {
    key: 'AIzaSyBzlLYISGjL_ovJwAehh6ydhB56fCCpPQw'
  },
  // Demonstrating how we can customize the name of the components
  installComponents: false,
});

document.addEventListener('DOMContentLoaded', function() {
    Vue.component('google-map', VueGoogleMap.Map);
    Vue.component('google-marker', VueGoogleMap.Marker);

    new Vue({
        el: '#root',
        data: {
          center: {lat: 10.0, lng: 10.0},
          markers: [{
            position: {lat: 10.0, lng: 10.0}
          }, {
            position: {lat: 11.0, lng: 11.0}
          }]
        },
    });
});

</script>

</body>

Thanks

Error in watcher "defaultPlace"

So here's my input:

<place-input :defaultPlace="value" @place_changed="updateValue" className="form-control" :id="label + 'Directions'"></place-input>

And when I type in it and select one of the available options, I get:

[Vue warn]: Error in watcher "defaultPlace" 
(found in component <GmapPlaceInput> at E:\dev\beerpilgrimage\node_modules\vue2-google-maps\dist\components\placeInput.vue)

Uncaught (in promise) TypeError: googleMapsElement[setMethodName] is not a function
    at VueComponent.vueElement.$watch.deep (eval at <anonymous> (main.js:126), <anonymous>:39:39)
    at Watcher.run (eval at <anonymous> (main.js:132), <anonymous>:1713:19)
    at flushSchedulerQueue (eval at <anonymous> (main.js:132), <anonymous>:1517:13)
    at Array.eval (eval at <anonymous> (main.js:132), <anonymous>:380:20)
    at nextTickHandler (eval at <anonymous> (main.js:132), <anonymous>:330:16)

The error appears to be in propsBinder.js at line 39?

Addition of Direction service

I'm wondering if it would be possible to integrate vue-google-maps with GoogleMaps direction service. Would I be able to render the map and then add directions onto it?

Help: Open Info Window

Hello,

I'm fully aware that this question was already asked here and as you suggested the solution to toggle the Info Window visibility is by

You have to listen for the marker_clicked event and then toggle
the marker's opened property.

But I'm having trouble by toggling the visibility only of the clicked marker.

So far I have my markers that looks like:

<gmap-marker 
       v-for="m in pushMarkers"
       :position="{lat: m.lat, lng: m.lon}" 
       @click="showInfoWindow()" >

        <gmap-info-window :content="m.name" :opened="visInfoWindow"></gmap-info-window>
 </gmap-marker>

Then In my data:

visInfoWindow: false,

And the showInfoWindow methods

showInfoWindow(){
        this.visInfoWindow = this.visInfoWindow ? false :true;
}

Unfortunately by doing so all the InfoWindow will be toggled when one marker is clicked.
Is there a way to reference only the one clicked?
For custom inputs I often listen for the $events.target; Is there an equivalent for the marker?

Thanks a lot for your help :)

Bounds and Zoom are not reactive

Thanks for the vue2 support.

When I use the basic example from readme I face several issues:

  1. Bounds don't set when initialized (in vue dev-tools they are undefined). As I understand, if I set center and zoom, bounds should be calculated automatically. How can I achieve this?

  2. When I change map zoom it is not changed if I look in the vue dev-tools. Is this expected behavior?

Thank you in advance.

fitBounds is not defined.

Given:

<gmap-map
      ref="map"
      :center="center"
    >
</gmap-map>

It doesn't mind:

vm.$refs.map.resize()

But

vm.$refs.map.fitBounds(vm.bounds)

Doesn't work: vm.$refs.map.fitBounds is not a function

However, this works:

vm.$refs.map.$mapObject.fitBounds(vm.bounds);

Error: Can't resolve 'marker-clusterer-plus'

Getting this error after installing:

ERROR in ./~/vue2-google-maps/dist/components/cluster.js
Module not found: Error: Can't resolve 'marker-clusterer-plus' in './node_modules/vue2-google-maps/dist/components'

If I do yarn add marker-clusterer-plus then I get another error:

error during render : ./node_modules/vue2-google-maps/dist/components/map.vue:1
(function (exports, require, module, __filename, __dirname) { <template>
                                                              ^
SyntaxError: Unexpected token <
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (./node_modules/vue2-google-maps/dist/components/mapElementMixin.js:11:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
(node:52424) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: window is not defined

Disable Street View on Map

Is there a quick way to do this? Hoping someone's had to do it before.

these didn't work...
<gmap-map street-view-control="false"></gmap-map>

<gmap-map streetViewControl="false"></gmap-map>

Heatmap

Could you add heatmap support? I'm doing my thesis with this lib, but i'm struggling to extend it.

PLZ help a bro out!

TypeError (0, u.default) is not a function

Hello, I have inlcuded your dist/vue-google-maps.js in my app, and get this error:

Uncaught TypeError: (0 , u.default) is not a function
    at Object.e.__esModule.default (vue-google-maps.js:7)
    at t (vue-google-maps.js:1)
    at Object.n (vue-google-maps.js:7)
    at t (vue-google-maps.js:1)
    at Object.<anonymous> (vue-google-maps.js:1)
    at t (vue-google-maps.js:1)
    at Object.<anonymous> (vue-google-maps.js:7)
    at t (vue-google-maps.js:1)
    at Object.<anonymous> (vue-google-maps.js:7)
    at t (vue-google-maps.js:1)

I am using Vue 2.1.8 what step did I miss?
Thanks for your great plugin ๐Ÿ‘

Use Vue.use()

Because the currently hackish method of exporting a compiled Webpack component is just messy and not compatible with the myriad ways in which Vue is used (runtime, standalone)

Error missing package

I am getting the error below. Anyone know why?

cluster.js?19a2:23 Uncaught Error: Cannot find module "marker-clusterer-plus"
    at webpackMissingModule (eval at <anonymous> (app.js:532), <anonymous>:23:92)
    at eval (eval at <anonymous> (app.js:532), <anonymous>:23:190)
    at Object.<anonymous> (app.js:532)
    at __webpack_require__ (app.js:20)
    at eval (eval at <anonymous> (app.js:539), <anonymous>:27:16)
    at Object.<anonymous> (app.js:539)
    at __webpack_require__ (app.js:20)
    at eval (eval at <anonymous> (app.js:560), <anonymous>:11:15)
    at Object.<anonymous> (app.js:560)
    at __webpack_require__ (app.js:20)

Components missing via webpack in 0.4.4

Just updated to the latest version and getting warnings regarding a couple of components missing:

[Vue warn]: Unknown custom element: <gmap-map> - did you register the component correctly? For recursive components, make sure to provide the "name" option. 
(found in component <map-component> at E:\dev\project\resources\assets\js\components\Map.vue)
[Vue warn]: Unknown custom element: <gmap-cluster> - did you register the component correctly? For recursive components, make sure to provide the "name" option. 
(found in component <map-component> at E:\dev\project\resources\assets\js\components\Map.vue)

In Map.vue:

<template>
  <gmap-map
        ref="map"
        :center="center"
        :zoom="7"
      >
      <gmap-marker
        v-for="brewery in toastedMarkers"
        :position="{lat: brewery.latitude, lng: brewery.longitude}"
        :icon="getBreweryIcon(brewery)"
        @click="openBrewery(brewery.id)"
        :optimized="brewery.toasted ? false : true"
      >
        <div>
          <gmap-info-window
            :opened="brewery.opened"
            @closeclick="closeBrewery(brewery.id)"
          >
            <card full="true" :brewery="brewery"></card>
          </gmap-info-window>
        </div>
      </gmap-marker>
      <gmap-cluster :styles="styles">
        <div>
          <gmap-marker
            v-for="brewery in markers"
            :position="{lat: brewery.latitude, lng: brewery.longitude}"
            :icon="getBreweryIcon(brewery)"
            @click="openBrewery(brewery.id)"
          >
            <div>
              <gmap-info-window
                :opened="brewery.opened"
                @closeclick="closeBrewery(brewery.id)"
              >
                <card full="true" :brewery="brewery"></card>
              </gmap-info-window>
            </div>
          </gmap-marker>
        </div>
      </gmap-cluster>
    </gmap-map>
</template>
<script>
import { gmapMap, gmapMarker, gmapCluster, gmapInfoWindow, loaded } from 'vue2-google-maps'
...
export default {
    components: { gmapMap, gmapMarker, gmapCluster, gmapInfoWindow, Card },
    ...
}
</script>

Interestingly enough, it isn't upset about the marker or info window, but that could be because those are nested in ones that are missing. Can anyone confirm this bug?

Why is `vue-loader` a dependency?

Looking at package.json, I see that vue-loader is a dependency. My understanding is that vue-loader is meant to be a dev dependency used with webpack. Shouldn't it be in the devDependencies section?

Autocomplete/PlaceInput

How do i use this component ?
Tried using gmap-autocomplete/gmap-place-input but still can't get it to work. Already Added 'places' in the libraries to load.


 <gmap-place-input
                label="Add a marker at this place"
                :select-first-on-enter="true"
   ></gmap-place-input>

placeInputImpl.js?9c97:104 The PlaceInput class is deprecated! Please consider using the Autocomplete input instead
placeInputImpl.js?9c97:93 Uncaught (in promise) TypeError: Cannot read property 'Autocomplete' of undefined
    at eval (eval at <anonymous> (packed-app.js:651), <anonymous>:93:54)

Autocomplete only working while `gulp watch` active

I'm developing on a homestead box and using Laravel Elixir. While using gulp watch and localhost:3000, the autocomplete functions just fine. However, if I simply navigate to the dev URL, the autocomplete doesn't work.

Futhermore, if watch is active and I load localhost:3000, then utilize the autocomplete and select a location, then go back to the command prompt and quit the watch, clicking into the autocomplete box again w/o refreshing the page gives me a dropdown with only the current value as an option. New options aren't generated.

Need help "automate fitBounds after deferredReady"

After the component mounted, I want to call the function fitBounds but unfortunately that seems to be not working because Google Maps library is not loaded completely yet.

In the below example, the fitBounds is called after mounted, and in the console, there is an error which says 'google' is undefined.

Thank for a small hint.

<body>
  <div id="root">
    <button @click="panTo">
      Pan To
    </button>

    <button @click="panToBounds">
      Pan To Bounds
    </button>

    <button @click="fitBounds">
      Fit Bounds
    </button>

    <div style="width: 100%; height: 500px">
      <gmap-map
        :center="center"
        :zoom="7"
        ref="mmm"
      >
        <gmap-marker
          v-for="m in markers"
          :position="m.position"
          :clickable="true"
          :draggable="true"
          @click="center=m.position"
        ></gmap-marker>
      </gmap-map>
    </div>
  </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.6/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.js"></script>
<script src="../dist/vue-google-maps.js"></script>

<script>

Vue.use(VueGoogleMap, {
--cropped---
});

document.addEventListener('DOMContentLoaded', function() {
    new Vue({
        el: '#root',
        data: {
          center: {lat: 10.0, lng: 10.0},
          markers: [{
            position: {lat: 10.0, lng: 10.0}
          }, {
            position: {lat: 11.0, lng: 11.0}
          }]
        },
        mounted() {
        	this.fitBounds();
        },
        methods: {
          fitBounds() {
            var b = new google.maps.LatLngBounds()

            b.extend({
              lat: 33.972,
              lng: 35.4054
            })
            b.extend({
              lat: 33.7606,
              lng: 35.64592
            })

            this.$refs.mmm.fitBounds(b);
          },
          panToBounds() {
            var b = new google.maps.LatLngBounds()

            b.extend({
              lat: 33.972,
              lng: 35.4054
            })
            b.extend({
              lat: 33.7606,
              lng: 35.64592
            })

            this.$refs.mmm.panToBounds(b);
          },
          panTo() {
            this.$refs.mmm.panTo({
              lat: 47.912867,
              lng: 106.910723
            });
          },
        }
    });
});

</script>

</body>

Set the zIndex

Hi all,
I am facing a problem when setting the zIndex for gmap-marker:
<gmap-marker v-for="m in markers" :position="m.position" :zIndex="m.zIndex" :clickable="true" :draggable="false" @click="center=m.position"> </gmap-marker>

markers: [{ position: {lat: 42.3666593, lng: -71.0994817}, title: "XXX", zIndex: 50, },

But the zIndex still looks like

zIndex: undefined prop
All other properties are set correctly...

Any glue? Thanks a lot!
martin

Uncaught ReferenceError: Marker is not defined

I'm using this package with Vue integrated to Laravel in bundle files with webpack. And when i'm calling gmap-map i'm having this error in console. Uncaught ReferenceError: Marker is not defined

Huge Data-Sets ( Inquiry Not Bug )

Any recommendations on how to plot lots of pins. 10,000 - I'd like the map to load, then start adding the pins (instead of waiting for all the pins to be placed, then loading).

I'll dig through your examples and see what I come up with - Just curious if anyone has a technique for this kind of thing. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.