February 17, 2018 at 2:16 am #34799
I have a site where I’m using polygons for state shapes and I wanted the polygons to show different corresponding data depending on the state that’s currently hovered over.
What I’ve done to make this work:
I’ve added: https://gist.github.com/KZeni/e98c464c62172f9d1c287a0750570e24
right after the: https://gist.github.com/KZeni/eccf510c5aff287e9422bbc437110c61
function in the js/core.js file (which is then minified for the version that’s served publicly).
This made it so hovering over each of the polygons had the corresponding Tabby Responsive Tab (3rd party plugin) toggled to show its relevant data.
I realize my implementation here is rather specific to my use case, but I’d think that there could be some way to have it so a hook / function is available for other developers to tap into for augmenting behaviors like this without needing to create custom edits to the core.js files of the plugin. That is, unless this is already possible and I’m just not looking at the right spot, of course!
Thanks for the great plugin!February 18, 2018 at 10:37 am #34808
Thank you for your kind words and time. We’ll look through your code and may use it in future release. Please note that we’re working on new plugin release v7 with tone of new features which should be released soon.
Thank you for your time in this.
JarekFebruary 19, 2018 at 6:55 pm #34852
Thanks!April 10, 2018 at 1:33 am #36449
Okay, version 7 is out. Just want to give this another mention for potential inclusion in the new version’s codebase (didn’t see it listed anywhere on https://trello.com/b/Brsxoyzo/wp-google-maps).April 10, 2018 at 10:21 am #36467
We’ve added a lot of features in our new plugin release and missed this feature. I’m sorry for this. We’ll take a look again at your work and discuss it if we can implement it to our V7 version.
Thank you for your time.
BestAugust 14, 2019 at 6:41 pm #53292
I see that v8 is updating the polygon offerings per https://www.wpgmaps.com/new-in-version-8/ (with demo at: https://www.wpgmaps.com/demo-polygon-labels-descriptions/).
Does this v8 update also accommodate this (having events/triggers for having external JS be triggered accordingly on the polygon event in a customizable/expandable way [ex. have mouseover on a polygon trigger an event specific to that polygon with that polygon’s data included which the site’s JS can listen for/be triggered by to then perform a specific action, such as toggling a tabbed content area found elsewhere on the webpage])?
As an aside, my implementation above is definitely rough & not how it would be done to make things customizable/expandable, but it’s what I implemented for my site in particular for my needs & provides a foundation for things.
Just wanted to see if this request was still unaddressed or not.
KurtAugust 15, 2019 at 7:16 am #53295
Thank you for getting in touch.
We don’t directly support this, however, you can follow Google’s documentation to bind to the polygons, which are contained in the global array WPGM_Path.
We can provide example code if you need.
Does that help?
– PerryOctober 11, 2019 at 11:57 pm #54829
I’ve come up with the following: https://gist.github.com/KZeni/20842ddc27483f22812191f45a934928
Does this look about right? Maybe this could be documented more formally since having a site act on marker events beyond what’s built into WPGM isn’t uncommon (as with polygons as my other recent post at https://www.wpgmaps.com/forums/topic/removereduce-visibility-of-polygon-border/#post-54773 effectively details [it’s about something else, but it handles it by altering the listener events of polygons as the workaround.])October 13, 2019 at 9:00 am #54857
This looks good yes, provided you’re not planning on switching to OpenLayers as there is a lot of Google specific code in here.
For broader applications we recommend binding to the WPGMZA.Marker rather than to a google.maps.Marker, this will work perfectly well in this particular instance though.
One change we would recommend is that you listen for `markersplaced.wpgmza` on the document body, then iterate over event.target.markers when that event fires. That way you won’t have to use timeouts, which can be unpredictable.
You must be logged in to reply to this topic.