npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-mapbox-gl

v0.6.8

Published

一个基于Vue3+Typescript封装的Mapbox地图组件

Downloads

120

Readme

vue3-mapbox-gl

一个基于Vue3+Typescript封装的Mapbox地图组件

安装

yarn add mapbox-gl vue3-mapbox-gl

引入

入口文件

import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import 'vue3-mapbox-gl/dist/style.css'
import mapbox from 'vue3-mapbox-gl'
const app = createApp(App)
app.use(mapbox, {
  accessToken: 'pk.xxxxxxxxxxxxx'
})
app.mount('#app')

对于ts项目需要在tsconfig.json里面配置types

{
  "compilerOptions": {
    "types": [
      // ...
      "vue3-mapbox-gl/global"
    ]
  }
}

BaseMap

<template>
  <Mapbox :options="options"></Mapbox>
</template>
<script lang="ts" setup>
import type { MapboxOptions } from 'mapbox-gl';
const options: Partial<MapboxOptions> = {
	style: 'mapbox://styles/mapbox/streets-v11',
	center: [0,0],
	zoom: 4
};
</script>

SourceAndLayer

<template>
  <Mapbox :options="options">
    <VectorTileSource url="mapbox://examples.8fgz4egr">
      <CircleLayer
        source-layer="sf2010"
        :style="{
          'circle-radius': {
            base: 1.75,
            stops: [
              [12, 2],
              [22, 180]
            ]
          },
          'circle-color': [
            'match',
            ['get', 'ethnicity'],
            'White',
            '#fbb03b',
            'Black',
            '#223b53',
            'Hispanic',
            '#e55e5e',
            'Asian',
            '#3bb2d0',
            '#ccc'
          ]
        }"></CircleLayer>
    </VectorTileSource>
  </Mapbox>
</template>
<script lang="ts" setup>
import type { MapboxOptions } from 'mapbox-gl'
const options: Omit<MapboxOptions, 'container'> = {
  style: 'mapbox://styles/mapbox/light-v11',
  zoom: 12,
  center: [-122.4473, 37.7535]
}
</script>

Hooks

<template>
  <Mapbox :options="options" :register="register">
    <Terrain
      url="mapbox://mapbox.mapbox-terrain-dem-v1"
      :exaggeration="1.5"></Terrain>
  </Mapbox>
</template>
<script lang="ts" setup>
import type { MapboxOptions } from 'mapbox-gl'
import { useMapbox, useChainCamera } from 'vue3-mapbox-gl'

const options: Partial<MapboxOptions> = {
  style: 'mapbox://styles/mapbox/satellite-v9',
  center: [107.132759, 34.784138],
  zoom: 4
}

const [register, { getMapInstance }] = useMapbox()
useChainCamera({
  map: getMapInstance,
  autoplay: true,
  list: [
    {
      lngLat: [138.73375, 35.41914],
      lookAtLngLat: [138.73036, 35.36197],
      altitude: 7000,
      duration: 0
    },
    {
      lngLat: [138.72649, 35.33974],
      lookAtLngLat: [138.73036, 35.36197],
      altitude: 6000.0,
      duration: 20000
    },
    {
      lngLat: [138.72623, 35.31977],
      lookAtLngLat: [138.73036, 35.36197],
      altitude: 6000,
      duration: 15000
    },
    {
      lngLat: [138.73375, 35.41914],
      lookAtLngLat: [138.73036, 35.36197],
      altitude: 7000,
      duration: 15000
    }
  ]
})
</script>

Components

Fog.vue

Image.vue

Light.vue

Marker.vue

Popup.vue

Terrain.vue

AttributionControl.vue

CustomControl.vue

FullscreenControl.vue

GeolocateControl.vue

NavigationControl.vue

ScaleControl.vue

BackgroundLayer.vue

CircleLayer.vue

CustomLayer.vue

FillExtrusionLayer.vue

FillLayer.vue

HeatmapLayer.vue

HillshadeLayer.vue

LineLayer.vue

RasterLayer.vue

SkyLayer.vue

SymbolLayer.vue

Mapbox.vue

CanvasSource.vue

GeoJsonSource.vue

ImageSource.vue

RasterDemSource.vue

RasterSource.vue

VectorTileSource.vue

VideoSource.vue

Hooks

useChainCamera.ts

useEaseTo.ts

useFitBounds.ts

useFitScreenCoordinates.ts

useFlyTo.ts

useJumpTo.ts

useAttributionControl.ts

useCustomControl.ts

useFullscreenControl.ts

useGeolocateControl.ts

useNavigationControl.ts

useScaleControl.ts

useLayerEventListener.ts

useMapEventListener.ts

useMapReloadEvent.ts

useCreateBackgroundLayer.ts

useCreateCircleLayer.ts

useCreateCustomLayer.ts

useCreateFillExtrusionLayer.ts

useCreateFillLayer.ts

useCreateHeatmapLayer.ts

useCreateHillshadeLayer.ts

useCreateLayer.ts

useCreateLineLayer.ts

useCreateRasterLayer.ts

useCreateSkyLayer.ts

useCreateSymbolLayer.ts

useCreateFog.ts

useCreateImage.ts

useCreateLight.ts

useCreateMapbox.ts

useCreateMarker.ts

useCreatePopup.ts

useCreateTerrain.ts

useCreateCanvasSource.ts

useCreateGeoJsonSource.ts

useCreateImageSource.ts

useCreateRasterDemSource.ts

useCreateRasterSource.ts

useCreateVectorTileSource.ts

useCreateVideoSource.ts

useGeoJsonSource.ts

useLayer.ts

useMapbox.ts