WordPress.org

Ready to get started?Download WordPress

Forums

How would you use Meta Value to mimic this Google Maps Query? (1 post)

  1. zumajoe
    Member
    Posted 3 years ago #

    So there is a wonderful example of using Google maps for a store locator here: http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html

    The example uses a simple table with 3 columns- address, latitude, longitude.

    I'm trying to integrate this in wordpress using Custom Post type for each new location, and i've successfully been able to save the address, latitude, and longitude value as meta data along with each new custom post.

    What i'm having a hard time doing is pulling this data/Query to convert to XML the same way that the google example provides.

    It would be nice to just keep all the data inside WordPress custom posts without creating an entire seperate table to handle it.

    Here is the standard example query:

    // Search the rows in the markers table
    $query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
      mysql_real_escape_string($center_lat),
      mysql_real_escape_string($center_lng),
      mysql_real_escape_string($center_lat),
      mysql_real_escape_string($radius));
    $result = mysql_query($query);

    How would you approach mimicking this to work within wordpress CPT meta data?

Topic Closed

This topic has been closed to new replies.

About this Topic