Comments (2)
hey @shieldcy
let say you have this code (that it try to use from your exemple)
<gmap-custom-marker
:marker="setMarker(pin.lat, pin.lng)"
:class="{addzIndex : pin.id == selectedId}"
>
<yout-custom-component/>
</gmap-custom-marker>
with your custom component like below :
<template>
<div
:ref="'marker_el_'+pin.id"
class="mapmarker"
tabindex="0"
@click="toggleBox(pin.id)"
>
<div class="price">
<span class="text">
€{{ pin.text }}
</span>
</div>
<div
v-if="selectedMapListing == pin.id"
class="box"
>
<div v-if="pin" class="thumbnail">
.....
</div>
<div class="detail">
.....
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('the map item', this.$parent.$map)
// Do some computation with the map object
}
}
</script>
Then it should be possible to compute your panel location depending on map information (this is google an underlaying map object you have to study) and compare it to your marker position then choose to move left or right some content of the custom marker (maybe making it larger and use relative / absolute positions)
I never had to do this but I would do it this way (maybe I am naive) the first time.
Is it clear enough or do you need something else ?
Eric
from vue2-gmap-custom-marker.
Thanks for your reply @eregnier
What I did in case anyone is interested (I am not sure if this is a good solution but it works):
I used a "ref" as eregnier mentioned above. And checked the position of the parent element to the child element
Parent element = whole map (mapPos)
Child element = marker popup box (popupPos)
toggleBox (id) {
// clearing the classes before re-adjusting
this.$refs['marker_el_' + id][0].classList.remove('adjustTop')
this.$refs['marker_el_' + id][0].classList.remove('adjustLeft')
this.$refs['marker_el_' + id][0].classList.remove('adjustRight')
// get the positions
let mapPos = this.$refs['map'].getBoundingClientRect()
let popupPos = this.$refs['marker_el_' + listingId][0].getBoundingClientRect()
let position = {}
position.top = popupPos.top - mapPos.top
position.right = popupPos.right - mapPos.right
position.left = popupPos.left - mapPos.left
// set the classes (the numbers used below are what I wanted based on the position of my map and popups
if (position.top <= 350) {
this.$refs['marker_el_' + id][0].classList.add('adjustTop')
}
if (relativePos.left <= 150) {
this.$refs['marker_el_' + id][0].classList.add('adjustLeft')
}
if (relativePos.right >= -150) {
this.$refs['marker_el_' + id][0].classList.add('adjustRight')
}
}
And in css I set position absolute to the marker popup
.adjustTop {
top: 0px !important;
position: absolute;
}
.adjustLeft {
left: 0px !important;
position: absolute;
}
.adjustRight {
right: 0px !important;
position: absolute;
}
from vue2-gmap-custom-marker.
Related Issues (20)
- Marker offsets completely off with new latest update HOT 2
- The custom marker doesn't display in the exact LatLng HOT 1
- Other google maps items getting activated on click. HOT 1
- Render 4k marker on map with cluster HOT 4
- zIndex HOT 4
- HotFix: typeerror: cannot read property 'repaint' of undefined at vuecomponent.zindex HOT 2
- vue-google-maps is no longer maintained HOT 6
- Can not using gmap custom maker in nuxt 2.0 typescript HOT 1
- Rotate Marker HOT 2
- GmapInfoWindow does not work HOT 3
- How to animate gmap custom marker
- [Feature request] How to animation gmap customer marker HOT 9
- Cluster image dont work HOT 2
- How to drag the marker? HOT 2
- How to get extra info in a cluster HOT 3
- Making this library for vue3-google-map HOT 4
- incompatibility with [email protected] cluster and custom marker HOT 5
- Displaced markers on page change in Nuxt HOT 3
- ERROR in ./node_modules/vue2-gmap-custom-marker/node_modules/gmap-vue/dist/main.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue2-gmap-custom-marker.