GithubHelp home page GithubHelp logo

brandonxiang / vueleaflet Goto Github PK

View Code? Open in Web Editor NEW
191.0 14.0 45.0 2.24 MB

Vue components for Leaflet maps

Home Page: http://vueleaflet.brandonxiang.top/

License: MIT License

Vue 74.09% HTML 2.03% TypeScript 23.88%
vue-components leaflet-map vue-leaflet vue components vite vitejs

vueleaflet's People

Contributors

brandonxiang 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

vueleaflet's Issues

Example code not working

Hello! I'm having some trouble getting the code from the readme to work. When you do this:

import map from "./components/Map.vue"

it imports an object of options, but not a Vue component. So when you use it in the example template:

<template>
  <map :zoom="zoom" :center="center">
      <tilelayer :url="url"></tilelayer>
      <marker :position="center"></marker>
    </map>
</template>

you get a Vue error. Should VueLeaflet.Map point to mapComponent instead?

Error Message "Map is already initialized"

Hello,

My project has two pages which include vueleaflet. I also use vue-router with those pages(/components). During the first visit (doesn't matter on which component) the map gets displayed as planned. When I then visit the page which contains the other map, I receive the following message: "Map container is already initialized.".

If you like you can try it out yourself visit templum.me, you should see the map displayed. Then head over to "Veransltatungsort" under "Hier finden sie uns" the other map should be displayed. Within console, the exception should get displayed.

As far as I saw in your code a solution would be freeing/destroying the map object on unmount. Or give the option to set the used id with a property.

Best Regards
Simon

Comparison with vue2-leaflet

Hi, Nice project.

I see this and vue2-leaflet as vueified leaflet project.
Could you please throw some light on how this project vueleaflet differes with vue2-leaflet as architectural point of view.

Thanks

Dynamic markers

I would like to be able to add a variable amount of markers over time. I currently use:

    <l-marker v-for="(params, user) in points"
              :key="user"
              :position="params.pos"
              :title="title"
              :opacity="opacity">
      <l-tooltip :content="user"></l-tooltip>
    </l-marker>

but no points are shown (points is initially empty). I can see they are present with the Vuex debug console. It seems vueleaflet doesn't handle dynamic marker creation in a map?

Example using this project.

I cloned this project and able to run the app.
But when I installed through NPM in my project, I am not able to see the map or say map component is not being attached.

Here is my index.js

import Vue from 'vue'
import Vuex from 'vuex'
import VueLeaflet from 'vueleaflet'
import App from './components/App.vue'
import Home from './components/Home.vue'
import Signup from './components/Signup.vue'
import Login from './components/Login.vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
Vue.use(VueResource)
Vue.use(VueRouter)
Vue.use(Vuex)

import auth from './auth'

Vue.http.headers.common['Authorization'] = auth.getAuthHeader().Authorization
// Check the user's auth status when the app starts
auth.checkAuth()

const store = new Vuex.Store()
Vue.use(VueLeaflet.plugin, store)

const routes = [
  {
    path: '/home',
    component: Home
  }, {
    path: '/login',
    component: Login
  }, {
    path: '/signup',
    component: Signup
  }]

const router = new VueRouter({routes: routes})

export const app = new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

here is Home.vue with map

<template lang="html">
<div class="full">
  <l-map :zoom="zoom" :center="center" :min-zoom="minZoom" :max-zoom="maxZoom" :attributionControl="attributionControl" :zoomend="zoomend">
    <l-tilelayer :url="url" :attribution="attribution"></l-tilelayer>
    <l-marker :position="center" :title="title" :opacity="opacity" :draggable="draggable">
      <l-tooltip content="a tooltip"></l-tooltip>
    </l-marker>
    <l-marker :position="marker" :title="title" :opacity="opacity" :draggable="false">
      <l-popup content="a popup"></l-popup>
    </l-marker>
  </l-map>

</div>
</template>

<script>
//import '../../node_modules/leaflet/dist/leaflet.css';

export default {
  data() {
    return {
      zoom: 13,
      center: [51.505, -0.09],
      marker: [51.500,0.00],
      minZoom: 8,
      maxZoom: 15,
      url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
      attribution: 'mymap',
      title: 'test-marker',
      opacity: 1,
      draggable:true,
      attributionControl:false,
    };
  },
  methods:{
    zoomend(){
      console.log(1)
    }
  }
};
</script>
<style lang="css">
.full{
  width:100%;
  height:100%;
}

#map,#next{
  height:100%;
}

body {
    padding: 0;
    margin: 0;
}

html,
body {
    height: 100%;
}
</style>

And index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Hello Vue</title>
    <!--link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css"-->
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/dist/leaflet.css">
  </head>
  <body>
    <div id="app"></div>    
    <script src="build/build.js"></script>
  </body>
</html>

In your example main.js

import VueLeaflet from './index'

That just I have replaced in my index.js as

import VueLeaflet from 'vueleaflet'

Where I am going wrong?

Map object reference

Hi, I'm wondering how could I access the map object to add some additional stuff. Couldn't see any of it in the docs.
I'd like to use vueleaflet as a base map (it worked straightforward ❤️ ) and extend it as I used to do before vue, using the object obtained from

map = new L.Map('map', ...

For example, I need to add another control to the map (Leaflet Draw) using this line.

map.addControl(drawControl);

any ideas? thanks

This dependency was not found in node_modules

I can not succeed to use the nom package using the vuejs web pack template.

I have this error when I try to import it:

import { MapComponent } from 'vue_leaflet'

I have the following error:

 ERROR  Failed to compile with 1 errors
This dependency was not found in node_modules:
* vue_leaflet
Did you forget to run npm install --save for it?

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.