Make Polygons Direct Link

New home Forums Pro Add-on Make Polygons Direct Link

Tagged: ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #9746
    BatT
    Member

    Cheers!
    First, thanks for making this great plug-in.

    I’ve had a small problem come up with the polygons. What I am trying to do is set-up a vendor map for a client. They are state-wide, and would like the user to be able to click on a region of a state map (metro, mountains, etc) and be directed to a map with the vendors in that region.

    The problem I have run into after setting up the polygons, is when a polygon is clicked is brings up info instead of linking to the correct page. I think the average user will be hard pressed to figure out they need to click that tiny text to be redirected.

    Thanks again!

    #9770
    Nick Duncan
    Keymaster

    Hi Bat
    Thanks for that. We are adding in a new option that allows you to make a click on a marker go directly to a link or open an infowindow. This will be released hopefully this week

    #9788
    BatT
    Member

    Awesome! Thank you very much!

    #9789
    BatT
    Member

    Also a nice add to the polygons would be a labeling ability, where a label is there for each polygon when the map loads.

    #10023
    jwrightspplus
    Member

    I have seen a couple of updates come through for the plug in but have not seen this feature added yet.

    I really like this plug in and its a great tool but the polygon user interaction is not what folks would normally expect to happen on a hover or click. Is there a hack we can put into place while you are working on releasing the clickable functionality?

    Thanks!

    John

    #10586
    BatT
    Member

    Where are we on the progress of this polygon function? I’m with John, it is quite imperative that we find a solution (if nothing else a workaround/’hack’) for this problem!!

    #10587
    jwrightspplus
    Member

    Well I have a hack to make the polygons clickable – but it’s a very rough hack, only accomplishes what I needed it to do, has no settings in the admin tool and it will be over written if and when WP Google Maps does an update. So user beware…

    But until the WP Google Maps team releases their more polished version of this feature hear you go.

    Open up the wp-google-maps-pro/js/core.js
    Right around line 1859 (at least that is where it at in my version) you should see the following piece of code:

    if (tmp_data['title'] !== "") {
             infoWindow_poly[polygonid] = new google.maps.InfoWindow();
             google.maps.event.addListener(WPGM_Path_Polygon[polygonid], 'click', function(event) {
                 infoWindow_poly[polygonid].setPosition(event.latLng);
                 content = "";
                 if (tmp_data['link'] !== "") {
                     var content = "<a href='"+tmp_data['link']+"'>"+tmp_data['title']+"</a>";
                 } else {
                     var content = tmp_data['title'];
                 }
                 infoWindow_poly[polygonid].setContent(content);
                 infoWindow_poly[polygonid].open(MYMAP[entry].map,this.position);
             }); 
            }

    This set’s up the click listener on the polygon.

    Change it to:

    if (tmp_data['title'] !== "") {
             infoWindow_poly[polygonid] = new google.maps.InfoWindow();
             google.maps.event.addListener(WPGM_Path_Polygon[polygonid], 'click', function(event) {
                 //infoWindow_poly[polygonid].setPosition(event.latLng);
                 //content = "";
                 if (tmp_data['link'] !== "") {
                     //var content = "<a href='"+tmp_data['link']+"'>"+tmp_data['title']+"</a>";
    				 window.location.href = tmp_data['link'];
                 } 
    			 //else {
                     //var content = tmp_data['title'];
                 //}
                 //infoWindow_poly[polygonid].setContent(content);
                 //infoWindow_poly[polygonid].open(MYMAP[entry].map,this.position);
             }); 
            }

    This will make the polygon clickable to whatever you set as the “URL” value for the polygon and get rid of the link in the info-window.

    You can see it in action at:

    http://dca.spplusparking.com/ (while it is up – its a proof of concept website so probably wont be up forever)

    Good luck.

    John

    • This reply was modified 5 years, 9 months ago by jwrightspplus.
    #10782
    BatT
    Member

    Killer job, sir.

    Commenting out most of that if/else statement, and adding “window.location.href = tmp_data[‘link’];” is perfect. Thank you very much, sir. Hopefully this leads to a correction in the plug-in in a near future update, so that we don’t have to ‘hack’ the plug-in every update.

    Cheers, John!

    #10944
    Nick Duncan
    Keymaster

    Nice work John 🙂
    Sorry guys, we’ll add this in soon. We have quite a long list of things to add but we’ll get there eventually. Please bare with us.

    Kind regards
    Nick

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Make Polygons Direct Link’ is closed to new replies.