简体   繁体   中英

How to set gmap-info-window of vue2-google-map that will place in the bottom of the marker.?

I have a marker with two info windows but they are same placed above the marker. I want to "oyeee" info window must be in the bottom side. this is my code:

<gmap-marker :position="toLocation" icon="http://maps.google.com/mapfiles/ms/icons/yellow-dot.png">

       <gmap-info-window :opened="true"
                         :options="{
                                     pixelOffset: { width: 0, height: 0 },
                                     content: `<b>Destination Address <br>
                                     ${toLocation.lat} , ${toLocation.lng}</b>`,
                          }"
        ></gmap-info-window>
        
        <gmap-info-window :opened="true"
                          :options="{
                                      pixelOffset: { width: 0, height: 0 },
                                      content: `<b>OYEEEEEEEEEEEEEEEEEEEEEEEEEE </b>`,
                           }"
        ></gmap-info-window>

</gmap-marker

output:

在此处输入图像描述

Anyone can help me how must be "oyeeeee" info window must be in the bottom side of the marker?

Since vue-google-maps library supports pixelOffset property for info-window component, info window position could be adjusted like this:

Note: to prevent overlapping, height offset should exceed info window height

<gmap-map :center="center" :zoom="zoom" ref="map">
      <gmap-marker
        :position="{ lat: location.lat, lng: location.lng }"
        :clickable="true"
        icon="http://maps.google.com/mapfiles/ms/icons/yellow-dot.png"
        @click="openInfoWindow(location)"
      />
      <gmap-info-window
        :position="{ lat: location.lat, lng: location.lng }"
        :options="{
          pixelOffset: {
            width: 0,
            height: -25,
          },
        }"
        :opened="infoBoxOpen"
        @closeclick="infoBoxOpen = false"
      >
        <div class="infoWindow">
          {{ location.name }}
        </div>
      </gmap-info-window>

      <gmap-info-window
        :position="{ lat: location.lat, lng: location.lng }"
        :options="{
          pixelOffset: {
            width: 0,
            height: -75,
          },
        }"
        :opened="infoBoxOpen"
        @closeclick="infoBoxOpen = false"
      >
        <div class="infoWindow">
          {{ location.name }}
        </div>
      </gmap-info-window>
</gmap-map>

Result

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM