Add docs folder

This commit is contained in:
Fawad Mirzad
2021-09-13 15:30:46 +02:00
parent db827d7607
commit 86f25061de
28 changed files with 1302 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
# List
`@fawmi/vue-google-maps` provides a set of Vue.js 3 components wrapping the Google Maps API v3.
Currently `Map`, `Marker`, `InfoWindow`, `Polyline`, `Polygon` and `Rectangle` are supported.
Other components are still under development.
Checkout getting started to read, how to install and use vue-google-maps

View File

@@ -0,0 +1,10 @@
# Advanced
`@fawmi/vue-google-maps` provides a set of Vue.js 3 components wrapping the Google Maps API v3.
Currently `Map`, `Marker`, `InfoWindow`, `Polyline`, `Polygon` and `Rectangle` are supported.
Other components are still under development.
Checkout getting started to read, how to install and use vue-google-maps

View File

@@ -0,0 +1,77 @@
# How to get if a clicked area is within polygon in Google Maps.
[Interactive example on Condesandbox](https://stackblitz.com/edit/vue-google-maps-marker-fnzw4j?file=src%2Fcomponents%2FComponentWithMap.vue)
## Example
```bash
// Source of JS implementation: https://github.com/mattwilliamson/Google-Maps-Point-in-Polygon/blob/master/maps.google.polygon.containsLatLng.js
<template>
<GMapMap
ref="myMapRef"
:click="true"
@click="handleClick"
:center="center"
:zoom="10"
map-type-id="terrain"
style="width: 100vw; height: 20rem">
<GMapPolygon
:options="{
clickable: false
}"
:clickable="false"
ref="mapPolygon"
:paths="paths"
/>
</GMapMap>
</template>
<script>
import {ref, onMounted} from "vue";
import {setupContainsLatLng} from '../util/is-point-within-polygon.js'
export default {
data() {
return {
center: {lat: 25.774, lng: -80.19},
paths: [
{lat: 25.774, lng: -80.19},
{lat: 18.466, lng: -66.118},
{lat: 32.321, lng: -64.757},
],
};
},
setup() {
const myMapRef = ref();
const mapPolygon = ref();
function handleClick(event) {
if (event.latLng?.lat) {
mapPolygon.value.$polygonPromise.then(res => {
let isWithinPolygon = res.containsLatLng(event.latLng.lat(), event.latLng.lng());
console.log({isWithinPolygon})
})
}
}
onMounted(() => {
myMapRef.value.$mapPromise.then(() => {
setupContainsLatLng();
})
})
return {
myMapRef,
mapPolygon,
handleClick
}
}
};
</script>
```