Feature Proposal: Add ability to show text labels within polygons

New home Forums Pro Add-on Feature Proposal: Add ability to show text labels within polygons

This topic contains 30 replies, has 7 voices, and was last updated by  KZeni 1 month ago.

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #36853

    Mike
    Member

    Thanks for the troubleshooting help, I really do appreciate it!

    I only seem to be able to choose API version 3.30 or 3.exp. 3.31 defaults back to 3.30: https://www.screencast.com/t/Roe5Gd6KMANu

    Maybe my theme is loading the Google Maps API? I’ll dig in and try to find the call to api-v3/api/js/31/8b/map.js

    #36925

    Mike
    Member

    So I can’t seem to find a reference, anywhere in my theme, to a Google Maps API version.

    Any clues on how I can update the API version being called? Is there an override I could use in functions.php to achieve it?

    #36986

    Mike
    Member

    [Update] Selecting 3.exp in settings allowed me to call the same API version as @kzeni but my container div still has an inline style of z-index:100;

    Any ideas how I can force the z-index on that container div to be higher? Z-index of the container only needs to be over 103 to fix the label issue I am having.

    #36991

    KZeni
    Member

    I knew I had experienced this issue as well! Here’s what I added to fix this:

    
    //change the z-index of the canvas elements parents to move them above polygon layer
    google.maps.event.addListenerOnce(MYMAP[mapid].map, 'idle', function(){
    //var canvasElements = document.getElementsByTagName('canvas');//plain js to get the elements
    var canvasElements = jQuery('canvas'); //jquery for easy cross-browser support
    	for(var i=0; i<canvasElements.length; i++){
    		canvasElements.parentNode.style.zIndex = 9999;
    	}
    });
    

    Add this to your already-modified core.js file after your polyLabel.set('position', polygon_center); snippet. That should take care of it.

    #36993

    Mike
    Member

    Thanks @kzeni you’re the man.

    Not working unfortunately for me. I’m getting this:

    TypeError: Cannot read property 'style' of undefined
    /wp-content/plugins/wp-google-maps-pro//js/core.js:3053
    Uncaught TypeError: Cannot read property 'style' of undefined
        at Wf.<anonymous> (core.js:3053)
        at Wf.<anonymous> (js?v=3.exp&key=AIzaSyAFjluvVt_1E74H1wDhKDnhXUQachTUl2Q&language=en_US&libraries=geometry%2Cplaces%2Cvisualization&ver=7.07p:119)
        at Object.trigger (js?v=3.exp&key=AIzaSyAFjluvVt_1E74H1wDhKDnhXUQachTUl2Q&language=en_US&libraries=geometry%2Cplaces%2Cvisualization&ver=7.07p:117)
        at b (common.js:126)
    • This reply was modified 1 year, 5 months ago by  Mike.
    #37029

    KZeni
    Member

    Ah… you’ll want to use this instead:

    
    //change the z-index of the canvas elements parents to move them above polygon layer
    google.maps.event.addListenerOnce(MYMAP[mapid].map, 'idle', function(){
    //var canvasElements = document.getElementsByTagName('canvas');//plain js to get the elements
    var canvasElements = jQuery('canvas'); //jquery for easy cross-browser support
    	for(var i=0; i<canvasElements.length; i++){
    		canvasElements[0].parentNode.style.zIndex = 9999;
    	}
    });
    

    Note that the only change is the addition of the [0] after the canvasElements variable so it turns a jQuery object into the native javascript element which parentNode can then act on properly.

    Screenshot: https://cloudup.com/crCjLQkxUP7 👍

    #37030

    Mike
    Member

    Thank you it worked!!!!

    How do I buy you a coffee/beer to say thanks?

    #37093

    KZeni
    Member

    No worries! I just want to help get this feature added to the official plugin. Showing that it’s field tested & fully working with multiple sites & people (ironing out the issues in a public space) may help the chances of it being adopted sooner than later so that’s all worth it (also, just happy to help).

    Glad to hear it’s working!

    #39075

    patmalyn
    Member

    Hello,

    I was just about to ask if it was possible to show the text title for a polygon opposed to clicking to see the title and then I saw this thread.

    Is this possible to do? And if so how do we do it without being a coding expert?

    Thanks

    #39198

    KZeni
    Member

    What I’ve provided has everything you need to get it to work with WP Google Maps 6.x (with myself and Mike confirming it works). However, this does involve some coding (I wouldn’t call it “expert” by any stretch, but it does involve editing plugin core files so it’s not really recommended if you’re familiar with disabling updates for the edited plugin, are manually managing it, or are otherwise familiar with things.)

    Again, I’d love to see this feature added officially by the team for the current version of WP Google Maps which is then more user friendly & doesn’t involve manually patching plugin files, but I haven’t seen too much from them on that aspect of things lately. Maybe you can reach out to them as well to show that there’s plenty of others looking for this and not just myself & Mike.

    #39299

    Perry
    Moderator

    KZeni, do you have the full file for the changes you’ve made you could send to me?

    We’d like to compare your full code against ours and merge this in for you.

    Kind regards
    – Perry

    #40001

    gilberj
    Member

    Is there any update on this feature being added? I just purchased the pro add-on expecting this feature along with the ability to add a link when the polygon area is clicked and was surprised to learn that these features aren’t included. I was able to find a fix for the linking in another thread, but haven’t resolved displaying text labels on the polygon. While this thread looks like a fix, it appears it only works on an older version. I otherwise love the plugin, but these features are the primary reason I purchased the pro add-on.

    #40078

    Perry
    Moderator

    Hi there

    I would need to see the changes made in order to merge them into our code.

    We do have plans for an office style “bring forward” / “send backwards” / “bring to front” / “send to back” menu, however there is no timeline for this at the time of writing.

    I apologise that we can’t be more forthcoming on this issue right now.

    Is there anything else I can help you with?

    Kind regards
    – Perry

    #49906

    Scott Jenvey
    Member

    Anyone know what the status of this is? This post is from April 2018 and was supposed to be implemented according to the moderator. “We’ll have to review the code at some point but I can’t see any reason why this wouldn’t be added to the core plugin files shortly,

    Thanks.

    #49920

    Steven
    Moderator

    Hi there,

    Thank you so much for getting in touch, and our sincerest apologies for the delay.

    This feature should be made available with the next major version release or update for V8 which is due some time soon.

    Our sincerest apologies for the trouble.

    Kindest Regards,
    Steven De Beer

Viewing 15 posts - 16 through 30 (of 32 total)

You must be logged in to reply to this topic.