PHP code example of hypejunction / hypegeo
1. Go to this page and download the library: Download hypejunction/hypegeo library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hypejunction / hypegeo example snippets
$current_user = elgg_get_logged_in_user_entity();
$lat = $current_user->getLatitude();
$long = $current_user->getLongitude();
$radius = 200 * 1000; // 200km in meters
$params = array(
'types' => 'user',
'full_view' => false,
// other getter and lister options
);
$params = \hypeJunction\Geo\add_distance_constraint_clauses($params, $lat, $long, $radius);
$params = \hypeJunction\Geo\add_order_by_proximity_clauses($params, $lat, $long);
echo elgg_list_entities($params);
$location = "Potsdamerstr. 56, Berlin";
$coords = elgg_geocode_location($location);
$lat = $coords['latitude'];
$long = $coords['longitude'];
$params = array(
'types' => 'object',
'subtypes' => array('blog','bookmarks'),
'full_view' => false,
// other getter and lister options
);
$params = \hypeJunction\Geo\add_distance_constraint_clauses($params, $lat, $long, 500);
echo elgg_list_entities($params);
$guid = get_input('guid');
$entity = get_entity($guid);
if (elgg_instanceof($entity)) {
$lat = $entity->getLatitude();
$long = $entity->getLongitude();
}
if ($lat && $long) {
$options = array(
'types' => 'group',
'metadata_name_value_pairs' => array(
'name' => 'featured_group', 'value' => 'yes'
),
'limit' => 20
);
$entities = \hypeJunction\Geo\get_entities_by_proximity($options, $lat, $long, 'elgg_get_entities_from_metadata');
echo elgg_view_entity_list($entities, array(
'pagination' => false,
'full_view' => false
));
}