mapbox gl js_Mapbox GL JS的Vue.js组件

本文档介绍了如何在Vue.js应用中使用Mapbox GL JS组件。首先,需要通过NPM安装,并在HTML文件中引入Mapbox GL JS和CSS文件。接着,通过全局引入Mapbox Gl到主JS文件。若使用Vueify,可按指定方式包含Mapbox组件。为显示地图,需在CSS中设置容器的高度和宽度。
摘要由CSDN通过智能技术生成

mapbox gl js

Mapbox GL JS Vue.js (Mapbox GL JS Vue.js)

A Vue.js Mapbox component.

Vue.js Mapbox组件。

Installation

安装

NPM

NPM

npm install mapbox-gl-vue --save

建立 (Setup)

This package does not include the Mapbox GL JS and CSS files. They need to be included in the <head> of your HTML file. See Mapbox GL quickstart guide here: https://www.mapbox.com/mapbox-gl-js/api/

该软件包不包括Mapbox GL JS和CSS文件。 它们需要包含在HTML文件的<head>中。 请参阅此处的Mapbox GL快速入门指南: https ://www.mapbox.com/mapbox-gl-js/api/

If you decide to pull in Mapbox Gl via npm and use a module bundler you need to require it globally from your main js file like this: window.mapboxgl = require('mapbox-gl');

如果您决定通过npm插入Mapbox Gl并使用模块捆绑程序,则需要从主js文件中全局要求它,如下所示: window.mapboxgl = require('mapbox-gl');

In your main js file:

在您的主要js文件中:

import Mapbox from 'mapbox-gl-vue';
const app = new Vue({
    el: '#app',
    components: {
        'mapbox': Mapbox
    },
]);

In your HTML file:

在您HTML文件中:

<!-- #app -->
<div id="app">
	<mapbox></mapbox>
</div>
Vueify (Vueify)

If you are using Vueify in your build script the Mapbox component can be included as follows:

如果在构建脚本中使用Vueify ,则可以按以下方式包含Mapbox组件:

Vue.component('mapbox', require('mapbox-gl-vue/src/components/Mapbox.vue'));
const app = new Vue({
    el: '#app'
]);
CSS (CSS)

CSS needs to be added for the map to show up. The #map container needs a height and a width. Example:

需要添加CSS才能显示地图。 #map容器需要高度和宽度。 例:

#map {
	width: 100%;
	height: 500px;
}

翻译自: https://vuejsexamples.com/a-vue-js-component-for-mapbox-gl-js/

mapbox gl js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值