LocationDataType.php in Search API Location 8
File
src/Plugin/search_api/data_type/LocationDataType.php
View source
<?php
namespace Drupal\search_api_location\Plugin\search_api\data_type;
use Drupal\search_api\DataType\DataTypePluginBase;
class LocationDataType extends DataTypePluginBase {
public function getValue($value) {
$geom = \geoPHP::load($value);
if ($geom) {
$centroid = $geom
->getCentroid();
$lon = $centroid
->getX();
$lat = $centroid
->getY();
return "{$lat},{$lon}";
}
else {
return $value;
}
}
}