forked from xkjyeah/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gmap-vue): update kml-layer component to a vue file
- Loading branch information
Showing
10 changed files
with
274 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: kml-layer | ||
--- | ||
# Kml-Layer | ||
KmlLayer component | ||
|
||
::: tip Tags | ||
**see**: [source code](/guide/kml-layer.html#source-code)<br />**see**: [Official documentation](https://developers.google.com/maps/documentation/javascript/kmllayer)<br /> | ||
::: | ||
|
||
## Table of contents | ||
[[toc]] | ||
|
||
## Props | ||
|
||
### url (`string`) | ||
::: tip Tags | ||
**see**: [KML layer options](https://developers.google.com/maps/documentation/javascript/kmllayer#kml_layer_options)<br /> | ||
::: | ||
|
||
|
||
|type|default|description| | ||
|:-|:-|:-|:-| | ||
|`string`|-|The URL of the .kml file| | ||
### map (`object`) | ||
::: tip Tags | ||
**see**: [KML layer options](https://developers.google.com/maps/documentation/javascript/kmllayer#kml_layer_options)<br /> | ||
::: | ||
|
||
|
||
|type|default|description| | ||
|:-|:-|:-|:-| | ||
|`object`|-|Specifies the Map on which to render the KmlLayer. You can hide a KmlLayer by setting this value to null within the setMap() method| | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script> | ||
import MapElementMixin from '../mixins/map-element'; | ||
import { getPropsValues, bindEvents, bindProps } from '../utils/helpers'; | ||
import { kmlLayerMappedProps } from '../utils/mapped-props-by-map-element'; | ||
/** | ||
* KmlLayer component | ||
* @displayName Kml-Layer | ||
* @see [source code](/guide/kml-layer.html#source-code) | ||
* @see [Official documentation](https://developers.google.com/maps/documentation/javascript/kmllayer) | ||
*/ | ||
export default { | ||
mixins: [MapElementMixin], | ||
props: { | ||
/** | ||
* The URL of the .kml file | ||
* @see [KML layer options](https://developers.google.com/maps/documentation/javascript/kmllayer#kml_layer_options) | ||
*/ | ||
url: { | ||
type: String, | ||
}, | ||
/** | ||
* Specifies the Map on which to render the KmlLayer. You can hide a KmlLayer by setting this value to null within the setMap() method | ||
* @see [KML layer options](https://developers.google.com/maps/documentation/javascript/kmllayer#kml_layer_options) | ||
*/ | ||
map: { | ||
type: Object, | ||
}, | ||
}, | ||
async provide() { | ||
const events = [ | ||
'click', | ||
'rightclick', | ||
'dblclick', | ||
'mouseup', | ||
'mousedown', | ||
'mouseover', | ||
'mouseout', | ||
]; | ||
// Infowindow needs this to be immediately available | ||
this.$map = await this.$mapPromise; | ||
// Initialize the maps with the given options | ||
const initialOptions = { | ||
// TODO: analyze the below line because I think it can be removed | ||
...this.options, | ||
map: this.$map, | ||
...getPropsValues(this, kmlLayerMappedProps), | ||
}; | ||
const { options: extraOptions, ...finalOptions } = initialOptions; | ||
this.$kmlLayerObject = new google.maps.KmlLayer(finalOptions); | ||
bindProps(this, this.$infoWindowObject, kmlLayerMappedProps); | ||
bindEvents(this, this.$infoWindowObject, events); | ||
this.$kmlLayerPromise = this.$kmlLayerObject; | ||
return { $kmlLayerPromise: this.$kmlLayerObject }; | ||
}, | ||
destroyed() { | ||
// Note: not all Google Maps components support maps | ||
if (this.$kmlLayerObject && this.$kmlLayerObject.setMap) { | ||
this.$kmlLayerObject.setMap(null); | ||
} | ||
}, | ||
}; | ||
</script> |
Oops, something went wrong.