wp-geo-posts icon indicating copy to clipboard operation
wp-geo-posts copied to clipboard

Geo locate Issue

Open cyaconiello opened this issue 11 years ago • 1 comments

When using a cloud site server it errors out because the servers ip has been blocked for MAX_QUERY_LIMIT being reach. the work around for this is changing a chunk of code in geo-post.php.

$location = $_POST['wp_gp_location'];
// Save the Location
update_post_meta($post_id, 'wp_gp_location', $location);

$location_san_spaces = str_replace(' ', '%20', $location);  
// Made this variable to swap spaces for %20's because urlencode() adds +'s which nominatim doesnt support

// Try to geolocate
$obj = json_decode(file_get_contents('http://nominatim.openstreetmap.org/search/' . $location_san_spaces . '?format=json'));
//Changed the obj from google to nominatim

// If successful
if($obj != '')
{
try
{
    if(empty($latitude))
    {
        $latitude   = $obj[0]->lat;
        update_post_meta($post_id, 'wp_gp_latitude', (string)$latitude);
                    //Change the obj -> lat
    }

    if(empty($longitude))
    {
        $longitude  = $obj[0]->lon;
        update_post_meta($post_id, 'wp_gp_longitude', (string)$longitude);
                    //Change the obj -> lon
    }
}
}

cyaconiello avatar Apr 05 '13 19:04 cyaconiello

http://nominatim.openstreetmap.org/search/4840%20Westgrove%20Rd,%20Virginia%20Beach,%20Virginia%2023455?format=json

http://wiki.openstreetmap.org/wiki/Nominatim

cyaconiello avatar Apr 05 '13 19:04 cyaconiello