Sourcefabric Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Newscoop 4.2 Cookbook

Geolocation search

The javascript/geocoding/map_search.js file has implemented a class for a map with the capability for the user to specify a search area. The area is selected via a half-transparent box. The output should be sent to the server where processed, as described below.

The search map can be used via the GetMapSearchHeader, GetMapSearchBody, and GetMapSearchCenter static methods of the Geo_Map class. They work in a similar way to the preview/tag functions. You can provide width and height values for the search map and optionally a list of four <div> ids for automatic storage of top-left and bottom-right longitude/latitude values. The values can be taken from the class by calling the get_top_left and get_bottom_right methods of an instantiated object.

An example of the visual search interface is in the admin-files/articles/locations/search.php file.

The Geo_Map::GetGeoSearchSQLQuery takes two coordinates - opposite corners of the search area - and it returns a SQL statement for the database search. The two corners should go from West to East, otherwise it would not be known whether the box goes over the 180/-180 meridian or not. It is as shown below:

// going east to west over the 180/-180, and south to north
$p_coordinates = array();
$p_coordinates[] = array("longitude" => "150", "latitude" => "20");
$p_coordinates[] = array("longitude" => "40", "latitude" => "60");

// going directly west to east, and north to south
$p_coordinates = array();
$p_coordinates[] = array("longitude" => "-10", "latitude" => "60");
$p_coordinates[] = array("longitude" => "40", "latitude" => "-20");

$query = Geo_Map::GetGeoSearchSQLQuery($p_coordinates);
echo $query;

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.