WordPress.org

Ready to get started?Download WordPress

Forums

Basic Google Maps Placemarks
[resolved] Changing Sort Order of List (7 posts)

  1. firesitedesign
    Member
    Posted 1 year ago #

    We are developing a GIS site with approximately 2,000 placemarks.

    We have stand alone pages with 100+ counties showing each list.

    Here's an example page:

    http://carolinasfirepage.com/gis/buncombe-county/

    Here's the issue: notice the list below the map.

    It is sorting like this:

    Sta 1 - Asheville
    Sta 10 - Asheville
    Sta 10 - Enka-Candler Sta 1
    Sta 10 - Enka-Candler Sta 2
    Sta 11 - Asheville
    Sta 11 - Riceville
    Sta 12 - Asheville
    Sta 12 - Upper Hominy Sta 1
    Sta 12 - Upper Hominy Sta 2
    Sta 14 - Reems Creek
    Sta 15 - Barnardsville
    Sta 16 - Jupiter
    Sta 17 - Beaverdam
    Sta 18 - Leicester Sta 1
    Sta 18 - Leicester Sta 2
    Sta 18 - Leicester Sta 3
    Sta 19 - French Broad
    Sta 2 - Asheville
    Sta 20 - Woodfin
    Sta 21 - Skyland Sta 1
    Sta 21 - Skyland Sta 2 - Avery Creek Station
    Sta 21 - Skyland Sta 3 - Bishop Station
    Sta 22 - Broad River Sta 1
    Sta 22 - Broad River Sta 2
    Sta 23 - Garren Creek Sta 1
    Sta 23 - Garren Creek Sta 2
    Sta 24 - Asheville Regional Airport
    Sta 3 - Asheville
    Sta 3 - Fairview Sta 1
    Sta 3 - Fairview Sta 2
    Sta 4 - Asheville
    Sta 4 - Black Mountain Sta 1
    Sta 4 - Black Mountain Sta 2
    Sta 4 - Black Mountain Sta 3 - Laurel Ridge
    Sta 5 - Asheville
    Sta 5 - West Buncombe
    Sta 6 - Asheville
    Sta 6 - Swannanoa Sta 1
    Sta 6 - Swannanoa Sta 2
    Sta 7 - Asheville
    Sta 8 - Asheville
    Sta 8 - Weaverville
    Sta 9 - Asheville

    We would like it to sort numerically:

    Sta 1
    Sta 2
    Sta 3
    Sta 4
    etc.....

    Any ideas on how to change this?

    Thanks in advance.

    jfh

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

  2. Ian Dunn
    Member
    Plugin Author

    Posted 1 year ago #

    Hi, that's called natural sorting.

    To sort the list, you'll have to write a custom PHP comparion function to re-order the array of posts based on a natural sorting of the title.

    Right now, there aren't any filters in BGMP to give you access to the $posts array in listShortcode(), but I just added one to the current development version. It's called bgmp_list-shortcode-posts, and will be available in version 1.9, which will be released in about a month. If you don't want to wait that long, you can check the Developers page in about 2-3 weeks for an early release (1.9-alpha2 or 1.9-rc1).

    Once you have 1.9, you can use that filter to re-order the posts before they get displayed. Here are a couple things to point you in the right direction:

    http://stackoverflow.com/questions/1462503/sort-array-by-object-property-in-php
    http://www.php.net/manual/en/function.usort.php
    http://php.net/manual/en/function.natsort.php

  3. firesitedesign
    Member
    Posted 1 year ago #

    Excellent.

    Thanks very much for the prompt response.

    This plug-in is ideal for our project.

    All the best,

    jfh

  4. harry
    Member
    Posted 1 year ago #

    Sorry if this is too obvious but why don't you just rename them,

    from 'Sta 1 - Asheville' to 'Sta 01 - Asheville' etc?

  5. firesitedesign
    Member
    Posted 1 year ago #

    That's a good suggestion.

    I will have some four-digit numbered stations, such as 2500, 2600, etc., so I would have to start everything like

    Sta 0001 - Asheville
    Sta 0002 - Asheville
    Sta 0003 - Asheville

    (which for my readers, would be fairly odd).

    Thanks for the idea.

  6. romainfevre
    Member
    Posted 1 year ago #

    Hi,

    With the 'bgmp_list-shortcode-posts', what arguments will be used : placemark title or/and categories or/and address ?

  7. Ian Dunn
    Member
    Plugin Author

    Posted 1 year ago #

    It will pass in an array containing arrays for each of the posts. The second-level arrays will contain all of the data that eventually gets put in the bgmpData.markers array in JavaScript. So, you'll be able to edit the info window title and content, marker coordinates, etc.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic