Search code examples
google-mapsvuejs2infowindowvue2-google-maps

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:

enter image description here

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


Solution

  • 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

    enter image description here