Support » Plugin: Basic Google Maps Placemarks » Filter Placemarks Revisited

  • Ian,
    I want to start off by saying awesome job. I’m really liking this plugin. Having said that, I wanted to revisit a post you made here: http://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-filter-placemarks?replies=3.

    I thought the markers were an overlay and could easily be hidden using jQuery. However, upon testing, it seems that the markers are a little more complicated than that. Is there a way to target a marker after it’s been created? When you create a new google.maps.Marker there’s no class or anything defined to differentiate the markers. Is that functionality that could be easily added? I was thinking it would be pretty easy to link them to their category since that’s how they are being shown/notshown already.

    If that is not the case then my next question is as follows: You mentioned using PHP to hide the classes. PHP itself is server side and wouldn’t be able to do this on the fly like javascript would. Could you think of a way that we could use AJAX to reload the map with new category options for the setBGMPMapShortcodeArguments filter?

    http://wordpress.org/extend/plugins/basic-google-maps-placemarks/

Viewing 15 replies - 1 through 15 (of 79 total)
  • I hit a snag using Jquery to reload the plugin. Basically, it gets stuck saying loading map and never loads.

    The code: http://pastebin.com/gc5VxRhR

    The javascript is the last item in the pastebin. Ive included the search form and the functions.php to make sure both are acting accordingly.

    The div does reload, as the post data does echo properly. It’s just that the map never reloads. You can see this for yourself here: http://tinyurl.com/cgqtujp.

    Plugin Author Ian Dunn

    (@iandunn)

    If you download the 1.9.3 release candidate, there’s a new bgmp.markers array in functions.js that you might be able to use to access the markers after they’ve been created.

    Ian,

    I apologize for the delay in responding. I am downloading the new RC now and will see if what comes of this. Thanks for your fast reply and I’m sorry I didn’t afford you the same courtesy.

    Ian,

    You’ll have to forgive my ignorance with Javascript, but how do I access bgmp.markers when it is contained inside the function bgmp_wrapper?

    To expand, I thought that since you call the function using the jQuery selector, I could access it using jQuery( or $(bgmp.markers), but alas, as I expected, it’s local and not global.

    Plugin Author Ian Dunn

    (@iandunn)

    Yeah, I think you’re right; the way it’s setup now, bgmp is a local variable. I’ll see if I can change that for the next RC.

    In the mean time, you may want to experiment with making it globalish, by attaching it to jQuery.

    Something like

    $.bgmp =
    {
        init : function()
        {
        }
    }

    Or just

    bgmp = ...

    … since leaving off the “var” will make it global.

    So to update on progress: removing the var did indeed set bgmp as a global variable. Playing around with the code a little bit I was able to get the items to hide properly when clicking a button: http://pastebin.com/cZNZFuAh.

    It’s very basic at the moment. The next step on my list is to push each marker into it’s own array based on the categories assigned via your plugin.

    It’d be a lot easier if you brought the categories over to the javascript already :\. Oh well hopefully in the next few days I can have something for you. Once Ive completed this, would you like to look over the code and possibly implement it into your plugin? It’s obviously quite a huge feature

    Plugin Author Ian Dunn

    (@iandunn)

    I’ve added the category info to bgmpData and attached bgmp to the jQuery object, so you should be able to access it as $.bgmp.markers.

    It’s pushed to trunk if you want to do your work against it. I’d love to see your final code once it’s done.

    excellent. I’m downloading it now. I’ll let you know what I have soon.

    I am able to pull in categories just fine. So now to build my list!

    Push Markers into Category Based Arrays:

    http://pastebin.com/QXhHyhvW

    Working on another project, so I won’t get to have a full show/hide going on based on categories. However, I am able to successfully hide by category. setVisible(true) didn’t work as I expected it to, so I’ll have to look at that tomorrow. The next step after that is to create a div and form with checkboxes to select/deselect categories. From what I can tell so far, the best way to support multiple categories and still be able to show/hide will be to hide all categories and then show only the ones checked off. Let me know if you can think of a better way of doing this.

    Hey,

    Thanks for showing me this.
    I see you almost got this all done, that’s really nice man 🙂
    I hope you are able to have it done somewhere before february 🙂

    I’ve run into a little snag…. it’s when I create the array. If I do:

    for (var s in categories) {
       title = categories[s]['name'];
       if (!$.bgmp.markers.[title]){
          $.bgmp.markers.[title] = [];
       }
    }
    $.bgmp.markers[title].push(marker);

    The markers work, hide/unhide with hardcoded javascript. However, when I do a bgmp.markers.length, it returns a 0. So I changed the code to

    for (var s in categories) {
       title = categories[s]['name'];
       if (!$.bgmp.markers.contains(title)){
          $.bgmp.markers.push(title);
       }
    }
    $.bgmp.markers[title].push(marker);

    the length is returned properly (3 for now), but the markers no longer work. My assumption is push does not function the same was as setting a key/value pair.

    The reason I am having this issue is because I am trying to create sample checkboxes from the key values of the bgmp.markers array, which is returning 0 on the first and $.bgmp.markers[title] is ignored in the second. Why is there such a difference between creating the array values that way?

    can’t edit… Oh well, obviously $.bgmp.markers.title.push(value) shouldn’t work, correct? I would imagine it would try and push into an array called title. But then again, a lot of stuff I would expect to work, doesn’t because of how funky javascript is..

    btw, bug in the code, the last } should be after the push.

Viewing 15 replies - 1 through 15 (of 79 total)
  • The topic ‘Filter Placemarks Revisited’ is closed to new replies.