Support » Fixing WordPress » How would you use Meta Value to mimic this Google Maps Query?

  • So there is a wonderful example of using Google maps for a store locator here:

    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",
    $result = mysql_query($query);

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

  • The topic ‘How would you use Meta Value to mimic this Google Maps Query?’ is closed to new replies.