```
v-mapbox components will work even if wrapped in another component as long as they are in the components sub-tree of the base map component.
For example:
**_Popup wrapper_**:
```vue
Hello world from wrapped popup!
```
**_Main component_**:
```vue
```
::: tip
VueMapbox internally use dependency injection mechanism (`provide/inject` in Vue [docs](https://vuejs.org)). It means that any component in `VMap` sub-tree can access to `map`, `mapbox` and `actions` through `inject` property.
:::
After successful mount all components emits `added` envent with Vue component object and additional data, such as corresponding Mapbox GL JS object or object containing layer id in payload.
================================================
FILE: docs/guide/controls.md
================================================
# Map controls
## Overview
Controls are UI elements for controlling the view of the map, such as scale or bearing.
You can check them out in Mapbox GL JS [documentation](https://docs.mapbox.com/mapbox-gl-js/api/#user%20interface)
In v-mapbox they exposed as Vue components, so you can control their properties and behavior dynamically by changing props.
_All controls_:
```vue
```
See list of controls and they properties in [API docs](/api/controls.md).
### Attribution control
Due to Mapbox [policy](https://docs.mapbox.com/help/how-attribution-works/) attribution control
is enabled by default. You can disable default attributions by setting
`attributionControl` prop of VMap to `false` and set your own attribution
using AttributionControl component.
================================================
FILE: docs/guide/index.md
================================================
# Quickstart
## Using as ES module
### Installation
You can install v-mapbox via npm. Take note that you need to install mapbox-gl as peer dependency:
```bash
npm install --save v-mapbox mapbox-gl
```
Add Mapbox JS and CSS files to the files where you need them:
```js
import 'mapbox-gl/dist/mapbox-gl.css'
import 'v-mapbox/dist/v-mapbox.css';
import Mapbox from "mapbox-gl"
import { VMap } from "v-mapbox"
```
## Using in browser
### Installation
Add Vue, MapboxGL and v-mapbox scripts on your page:
```html
```
All components will be placed in global VueMapbox object (`VueMapbox.VMap` etc.)
================================================
FILE: docs/guide/layers-and-sources.md
================================================
# Layers and sources
## Adding layers
Geographic features on the map draws as layers.
Layer use `source` object that contains data for layer (for example, GeoJSON object). Source must be added to map and several layers can use common `source` and draw it's data differently.
Also, layer has own configuration object that declares how layer draws on the map. You can read more about it in Mapbox GL JS docs for [sources](https://docs.mapbox.com/mapbox-gl-js/api/#sources) and [layers](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).
v-mapbox exposes layers as Vue components.
`source` and `layer` configuration object passed to layer component as props. There is several layers types for drawing different types of sources.
For example adding a layer with GeoJSON data:
```vue
```
In this example `geoJsonSource` can be an `object`, representing GeoJSON feature or `string` with URL to GeoJSON.
Sources are stored in Mapbox GL JS `Map` object by `sourceId`. If you sure that source already added to map, you can skip `source` prop and just pass `sourceId` and use same source for different layers. If you try to add same source with same `id` twice, VueMapbox would just use `source` that already existed on the map, but you can set `replaceSource` prop to `true` to just replace old source with new one passed in `source` prop.
By default when Layer components destroying, it removes source from map. If you want to keep source on Map (for example, for future using or if other layers use this source), set `clearSource` prop to `false`.
## Reactivity
Layer components watch for changes in object in their `layer` prop and translate changes to map accordingly. For example, if you change content of `filter` prop in GeojsonLayer, changes will be automatically applied to layer on the map. Not all layer settings can be set dynamically, currently reactive properties are `minzoom`, `maxzoom`, `paint`, `layout` and `filter`.
## Layer getters
GeoJSON and Vector layers has getters for their features: `.getRenderedFeatures(filter?)`, `.getSourceFeatures(geometry?, filter?)` and `.getFeatureState(featureId)`. They works similar to [`.queryRenderedFeatures()`](https://docs.mapbox.com/mapbox-gl-js/api/#map#queryrenderedfeatures) and [`.querySourceFeatures()`](https://docs.mapbox.com/mapbox-gl-js/api/#map#querysourcefeatures) Map methods, but returns features only from source of current layer.
## Layer methods
Layer components has methods `move()` and `remove()`.
First moves a layer to a different z-position. Second destroys component and removes layer and source from map event if layer created with prop `clearSource: false`.
## Layer events
Layers emits events when loading data or on user interaction like `click`. See full list of events in [API section](/api/Layers/index.md#events)
## Migration from 0.1
In versoin `0.1` layer and source options was exposed via separate props.
Since `0.2` there are consolidated `source` object props for data source and `layer` for layer options. See [sources](https://docs.mapbox.com/mapbox-gl-js/api/#sources) and [layers](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers) in Mapbox GL JS docs.
================================================
FILE: docs/guide/markers-and-popups.md
================================================
# Markers and Popups
## Marker
The Marker component is a wrapper around the [Mapbox GL Marker API](https://docs.mapbox.com/mapbox-gl-js/api/#marker).
```vue
```
### Props
- `color {String}` Set the color of the default marker (not applicable when using the `marker` slot)
- `coordinates {Array}` The GeoJSON coordinates for marker placement on the map
- `offset {Object, Array}` Display the marker at an offset distance from the coordinates
Full list of props you cab see on [API page](/api/marker.md#props)
### Slots
The Marker component has two slots: the `marker` slot and default slot used for popup.
#### The `marker` slot
The `marker` slot allows you to customize the look of the marker. Here is an example of using the [Vuetify `v-icon` component](https://vuetifyjs.com/en/components/icons) instead of the default marker icon:
```vue
mdi-map-marker
```
### Default slot
Default slot allows you to specify content to display in a Mapbox popup when the marker is clicked. See [below](#markers-popups-together)
## Popup
The Popup component is wrapper around the [Mapbox GL Popup API](https://docs.mapbox.com/mapbox-gl-js/api/#popup).
You can specify content inside popup in default slot. It can be HTML or Vue component.
In this example [Vuetify card component](https://vuetifyjs.com/en/components/cards) used as a content for popup:
```vue
Hello, I'm popup!
```
If you set `onlyText` prop to `true` content in Popup default slot will be treated as plain text. It can be useful if you loading popup content from external untrusted source.
Popups added to the map is hidden by default. If you want to show the popup immediately you need to set the prop `showed` to `true`
### Props
- `showed {Boolean}` If `true`, the popup shows immediately after component is created.
- `closeButton {Boolean}` If `true`, a close button will appear in the top right corner of the popup.
- `closeOnClick {Boolean}` If true, the popup will closed when the map is clicked.
- `closeOnMove {Boolean}` If true, the popup will closed when the map moves.
- `focusAfterOpen {Boolean}` If true, the popup will try to focus the first focusable element inside the popup.
- `coordinates {Array}` The GeoJSON coordinates for popup placement on the map. If popup used inside marker this prop will be ignored.
- `anchor {string}` prop specifies the part of the Popup that should be positioned closest to the coordinates point.
Full list of props you can see on [API page](/api/popup.md#props)
## Markers & Popups together
Popup often used inside of map markers. You can achive this by passing Popup inside Marker in default slot:
```vue