3.1.0 • Published 6 days ago

longdo-map-vue v3.1.0

Weekly downloads
85
License
MIT
Repository
github
Last release
6 days ago

Installation

You can easily install by using npm

npm i longdo-map-vue

Usage

First, you need to get a Longdo Map API key. Then, after you have Longdo Map API key and component installed, you need to register it to your Vue project.

There are two ways of registering component:

Register component globally

This is a recommended way of registering component

In your main.js or similar file:

import { createApp } from 'vue'
import App from './App.vue'
import LongdoMap from 'longdo-map-vue'

createApp(App)
  .use(LongdoMap, {
    load: {
      apiKey: 'YOUR_LONGDO_MAP_API_KEY',
    }
  })
  .mount('#app')

Then you can use <longdo-map /> in your component template.

<template>
  <longdo-map />
</template>

Register component locally

In your component file, for example Foo.vue:

<script setup>
import { LongdoMapLoad, LongdoMap } from 'longdo-map-vue'

LongdoMapLoad({
  apiKey: 'YOUR_LONGDO_MAP_API_KEY',
})
</script>

<template>
  <longdo-map />
</template>

You can import more components if you want, for example:

import { LongdoMapLoad, LongdoMap, LongdoMapMarker, LongdoMapPolyline } from 'longdo-map-vue'

Examples

Add a polygon to Longdo Map:

<script setup>
const locationList = [
  { lon: 99, lat: 14 },
  { lon: 100, lat: 13 },
  { lon: 102, lat: 13 },
  { lon: 103, lat: 14 }
]
</script>

<template>
  <longdo-map>
    <longdo-map-polygon
      :location="locationList"
      :lineWidth="2"
      :lineColor="'rgba(0, 0, 0, 1)'"
      :fillColor="'rgba(255, 0, 0, 0.4)'"
    />
  </longdo-map>
</template>

Add multiple markers to Longdo Map:

<template>
  <longdo-map :zoom="10" :last-view="false">
    <longdo-map-marker
      v-for="(item, i) in markers"
      :key="i"
      :location="item.location"
      :title="item.title"
      :detail="item.detail"
    />
  </longdo-map>
</template>

Using Longdo Map object:

<script setup>
function loadMap(map) {
  map.Layers.setBase(longdo.Layers.NORMAL)
}
function addMarker(marker) {
  console.log(marker.location())
}
</script>

<template>
  <longdo-map @load="loadMap">
    <longdo-map-marker @add="addMarker" :location="{ lon: 99, lat: 14 }" />
  </longdo-map>
</template>

Components

Map

  • Props
  • Event: @load="Function(object)"
<longdo-map :zoom="10" :last-view="false" />

Overlay

  • Props
  • Event: @add="Function(object)"
<longdo-map>
  <longdo-map-marker :location="{ lon: 99, lat: 14 }" :title="'Home'" :detail="'My home'" />
</longdo-map>

Geometry

longdo-map-dot, longdo-map-circle, longdo-map-rectangle, longdo-map-polyline, longdo-map-polycurve, longdo-map-polygon

  • Props
  • Event: @add="Function(object)"
<longdo-map>
  <longdo-map-polygon
    :location="[{ lon: 100.123, lat: 13.579 }, ...]"
    :lineWidth="2"
    :lineColor="'rgba(0, 0, 0, 1)'"
    :fillColor="'rgba(255, 0, 0, 0.4)'"
  />
</longdo-map>

Documentation

Community

3.1.0

6 days ago

3.0.2

8 months ago

3.0.0-next.0

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.0

2 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago