Skip to content

Commit 5ab6231

Browse files
committed
docs: describe how to access ol/Map
closes #215
1 parent 0c38dc3 commit 5ab6231

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/componentsguide/map/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,34 @@ Other events that emit [`ol.MapEvent`](http://openlayers.org/en/latest/apidoc/mo
7676

7777
## Methods
7878

79+
You have access to all Methods from the underlying source.
80+
Check out [the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_Map.html) to see the available methods.
81+
82+
To access the source, you can use a `ref()` as shown below:
83+
84+
```vue
85+
<template>
86+
<ol-map ref="mapRef">
87+
<!-- ... -->
88+
</ol-map>
89+
</template>
90+
91+
<script setup lang="ts">
92+
import { ref, onMounted } from "vue";
93+
import type Map from "ol/Map";
94+
95+
const mapRef = ref<{ map: Map }>(null);
96+
97+
onMounted(() => {
98+
const map: Map = mapRef.value?.map;
99+
// call your method on `map`
100+
const size = map.getSize();
101+
});
102+
</script>
103+
```
104+
105+
Furthermore the following methods are directly exposed and can be use as describe above, using a `ref=""`.
106+
79107
### focus()
80108

81109
Triggers focus on map container.

0 commit comments

Comments
 (0)