admin管理员组文章数量:1277903
So I've got my infowindow and marker working, but I don't know how to make it so that it appears above the marker like the example:
what mine looks like is this:
This is because it's using a position, rather than the Marker
object. How would I get this object and pass it to the InfoWindow? Code below.
html file
<div>
test
<gmap-map
:center="center"
:zoom="7"
style="width: 100%; height: 300px"
>
<gmap-marker
:key="index"
v-for="(m, index) in markers"
:position="m.position"
:clickable="true"
:draggable="true"
:label="m.label"
@click="openWindow"
/>
<gmap-info-window
@closeclick="window_open=false"
:opened="window_open"
:position="infowindow"
>
Hello world!
</gmap-info-window>
</gmap-map>
<table>
<thead>
<tr></tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</div>
vue file
export default {
data () {
return {
center: {lat: 10.0, lng: 10.0},
markers: [
{
label: "A",
position: {lat: 10.0, lng: 10.0}
},
{
label: "B",
position: {lat: 11.0, lng: 11.0}
}
],
info_marker: null,
infowindow: {lat: 10, lng: 10.0},
window_open: false
}
},
methods: {
openWindow () {
this.window_open = true
}
}
}
So I've got my infowindow and marker working, but I don't know how to make it so that it appears above the marker like the example: https://developers.google./maps/documentation/javascript/examples/infowindow-simple
what mine looks like is this:
This is because it's using a position, rather than the Marker
object. How would I get this object and pass it to the InfoWindow? Code below.
html file
<div>
test
<gmap-map
:center="center"
:zoom="7"
style="width: 100%; height: 300px"
>
<gmap-marker
:key="index"
v-for="(m, index) in markers"
:position="m.position"
:clickable="true"
:draggable="true"
:label="m.label"
@click="openWindow"
/>
<gmap-info-window
@closeclick="window_open=false"
:opened="window_open"
:position="infowindow"
>
Hello world!
</gmap-info-window>
</gmap-map>
<table>
<thead>
<tr></tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</div>
vue file
export default {
data () {
return {
center: {lat: 10.0, lng: 10.0},
markers: [
{
label: "A",
position: {lat: 10.0, lng: 10.0}
},
{
label: "B",
position: {lat: 11.0, lng: 11.0}
}
],
info_marker: null,
infowindow: {lat: 10, lng: 10.0},
window_open: false
}
},
methods: {
openWindow () {
this.window_open = true
}
}
}
Share
Improve this question
asked Apr 13, 2018 at 7:22
A. LA. L
12.7k29 gold badges98 silver badges178 bronze badges
1
-
Maybe change
infowindow: {lat: 10, lng: 10.0}
toinfowindow: {lat: 0, lng: 0}
? – Belmin Bedak Commented Apr 13, 2018 at 8:29
1 Answer
Reset to default 11you can set pixelOffset
to the info window to fix this.
<gmap-info-window
@closeclick="window_open=false"
:opened="window_open"
:position="infowindow"
:options="{
pixelOffset: {
width: 0,
height: -35
}
}"
>
demo https://codesandbox.io/s/jj972nj273
本文标签: javascriptvuegooglemap set infowindow to be above a markerStack Overflow
版权声明:本文标题:javascript - vue-google-map set infowindow to be above a marker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741246460a2364969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论