Skip to content

Commit

Permalink
fix(gmap-vue): set default vallue of contentn prop to undefined
Browse files Browse the repository at this point in the history
In this way we avoid to override the slot content at run time

Fix: #254
  • Loading branch information
diegoazh committed Mar 2, 2022
1 parent 75def11 commit bee86ad
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/documentation/docs/code/components/info-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ title: info-window

| Prop name | Description | Type | Values | Default |
| ------------- | ----------- | --------- | ----------- | ----------- |
| content | Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.<br/>`@value` ''<br/>`@see` [InfoWindow content](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.content) | string\|object | - | '' |
| content | NOTE: This prop overrides the content of the default slot, use only one of them, not both at the same time<br/>Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.<br/>`@value` undefined<br/>`@see` [InfoWindow content](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.content) | string\|object | - | undefined |
| opened | Determines if the info-window is open or not | boolean | - | true |
| position | Contains the LatLng at which this info window is anchored.<br/>Note: An InfoWindow may be attached either to a Marker object<br/>(in which case its position is based on the marker's location)<br/>or on the map itself at a specified LatLng.<br/><br/>The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.<br/>`@value` undefined<br/>`@type` LatLng\|LatLngLiteral<br/>`@see` [InfoWindow position](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.position) | object | - | undefined |
| zIndex | All InfoWindows are displayed on the map in order of their zIndex, with higher values displaying in front of InfoWindows with lower values. By default, InfoWindows are displayed according to their latitude, with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. InfoWindows are always displayed in front of markers.<br/>`@value` 0<br/>`@see` [InfoWindow position](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.zIndex) | number | - | 0 |
Expand Down
37 changes: 36 additions & 1 deletion packages/documentation/docs/guide/info-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
props: {
content: {
type: [String, Object],
default: '',
default: undefined,
},
opened: {
type: Boolean,
Expand Down Expand Up @@ -188,6 +188,41 @@ const events = ['domready', 'closeclick', 'content_changed'];

## How to use it

::: warn

If you only need to display a simple text, from **v3.4.3**, we added a new prop called `content` and you can use it to pass data to the `InfoWindow` component, it accepts HTML too but take care about it because **it has precedence** over the slot **use only one of both options**.

If you need to pass an entire block of HTML is better and simplest to use the default slot for it and leave the content prop empty. Doing that you have more flexibility and control over your HTML content.

:::

From v3.4.3

```vue
<template>
<gmap-map :center="center" :zoom="15" style="width: 100%; height: 500px">
<gmap-info-window
content="This is my info window content"
:options="infoOptions"
:position="infoWindowPos"
:opened="infoWinOpen"
@closeclick="infoWinOpen=false"
/>
<gmap-marker
:key="i"
v-for="(m,i) in markers"
:position="m.position"
:clickable="true"
@click="toggleInfoWindow(m,i)"
>
</gmap-marker>
</gmap-map>
</template>
```

or use the default slot as below

```vue
<template>
<gmap-map :center="center" :zoom="15" style="width: 100%; height: 500px">
Expand Down
5 changes: 3 additions & 2 deletions packages/gmap-vue/src/components/info-window.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ export default {
},
props: {
/**
* NOTE: This prop overrides the content of the default slot, use only one of them, not both at the same time
* Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.
* @value ''
* @value undefined
* @see [InfoWindow content](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.content)
*/
content: {
type: [String, Object],
default: '',
default: undefined,
},
/**
* Determines if the info-window is open or not
Expand Down

0 comments on commit bee86ad

Please sign in to comment.