Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Ian Dunn

    (@iandunn)

    The Installation page describes how to assign placemarks to categories.

    The loadResources() function in core.php gets the markers from the getPlacemarks() function and outputs the data in a JavaScript variable in the rendered page. The shortcode parameters determine which categories are selected.

    In other words, the PHP functions push the data to functions.js, rather than functions.js pulling the data from the PHP functions.

    If you want to change the behavior, you’d have to modify the plugin.

    Thread Starter mlh1407

    (@mlh1407)

    push instead of pull … that makes sense i just want access to the array of cattegories because i want to try and build a drop down wherein the user can filter the shown markers by categories ..
    i thought i had it with the get_categories() function but it gives me the categories for the posts not the placemarks..
    i have ben looking at loadResources and getPlacemarkers but i cant find a way to get theese categories to the javascript ..
    what is this variable called in functions.js ? maybe that will help me ..
    best regards
    Martin

    Plugin Author Ian Dunn

    (@iandunn)

    You would need to edit getPlacemarks() so that it includes the marker’s category as part of the array. Something like:

    $placemarks[] = array(
    	'title'		=> $pp->post_title,
    	'latitude'	=> get_post_meta( $pp->ID, self::PREFIX . 'latitude', true ),
    	'longitude'	=> get_post_meta( $pp->ID, self::PREFIX . 'longitude', true ),
    	'details'	=> nl2br( $pp->post_content ),
    	'icon'		=> is_array($icon) ? $icon[0] : plugins_url( 'images/default-marker.png', __FILE__ ),
    	'zIndex'	=> get_post_meta( $pp->ID, self::PREFIX . 'zIndex', true ),
    	'category'	=> 'foo'
    );

    Then in the JavaScript you’d have to loop through the markers and turn off the ones where the ‘category’ was equal to the selected one, etc. You might run into problems accessing the markers in JavaScript, but there’s probably a way around that.

    Thread Starter mlh1407

    (@mlh1407)

    thats what i have been working on for hours now ..
    i added an extra value at the end of placemarks and then in functions createMarker i added an extra parameter … it works fine i can alert whatever value i prefer.
    the problem is that i dont know how to get ′foo′ aka categories.
    is it in here:
    $query[‘tax_query’] = array(
    array(
    ‘taxonomy’ => self::TAXONOMY,
    ‘field’ => ‘slug’,
    ‘terms’ => $categories
    )
    );
    or am i totally off ?.
    Best regards
    Martin

    Plugin Author Ian Dunn

    (@iandunn)

    You don’t need to change the $query, you need to do something like:

    'category' => wp_get_object_terms( $pp->ID, self::TAXONOMY, $args );

    Would be a great feature to the plugin if we could filter categories some how.
    the other feature is missing is the actual linking of the item Placemark to the Placemark map not an exterior one.

    Anyone knows how to do this?

    I was using the connections plugin but I like this plugin way more.
    the filter is the only thing missing.

    And the linking withing the same map as a bonus feature ??

    Great job iandunn ! keep up the good work

    Any donations link?

    Hi,

    I need filter category option. I am willing to pay for this modification. Is there any available for making this? I need it urgently

    Thread Starter mlh1407

    (@mlh1407)

    I am working on a feature like that at the moment – in that process i have come up with some ideas that i think will do the trick for you.
    you will have to add some more code to the javascript and the php file (functions.js and core.php ) – in core.php it would be something like: category’ => wp_get_object_terms( $pp->ID, self::TAXONOMY, $args ) – and then in functions.js (where you extract the data ) you could make an array of all the placemarks ,an a array with the cattegories for the drop down menu and a multidimensional array with the categories assigned to each of them .. then when you create your map you can instatiate placemarks on the map based on a search in the array – in a loop i guess.
    It worked for me ..

    Plugin Author Ian Dunn

    (@iandunn)

    mlh1407, if you want to send me your modified code I can consider merging it into the official release.

    Thread Starter mlh1407

    (@mlh1407)

    Hi Ian – My code is a bit messy – I can sendt you
    the lot later today but I will not have the time to clean it up and comment it before after
    Xmas – hope thats ok.
    I used the fancybox liberary to show the contents of the placemarks and to make it easy to read mayby i should write that part out.

    Thread Starter mlh1407

    (@mlh1407)

    Ian – I have sendt you my code – with the fancybox solution – I am working on a test with jquery ui ( jqueryui.com ) also and have not yet decided which i will use for my project.

    i would like it if the admin could also clik on the map to create a placemark as not all locations in my project has an adress – can you point me to where in the code i should rewrite that if i would like to test that ?

    Plugin Author Ian Dunn

    (@iandunn)

    Cool, thanks. I won’t have time to check it out until after Christmas either.

    For placemarks that you don’t have an exact address for, you could use this page to get the coordinates, and then enter them into the Address box. If you want to build that into the program, I’d check out the source code of that page to see how they do it. You’d probably just need to edit the functions.js file and add create a function that fires on the click event.

    HI, thank you for your Plug-in realy like it!
    what I need really is the Category Filter option, I would like (Igess like “aslanov“) (on the map) to be able to see the placemarks of a category that I click on, let say Category 1, category, category3 each time I chose ? category just the places of this category will apear in the map.

    Many thanks of your answer.
    @mlh1407 could you send a URL to see how it lock like

    Thread Starter mlh1407

    (@mlh1407)

    gomtar – I cant send you the url cause its not up yet

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Plugin: Basic Google Maps Placemarks] filter by category workaround idea’ is closed to new replies.