protected function Field::getGeojsonFeatures in Openlayers 7.3
Compute the GeoJSON features array.
Return value
array The geojson array.
1 call to Field::getGeojsonFeatures()
- Field::getJS in modules/
openlayers_field/ src/ Plugin/ Source/ Field/ Field.php - !Attention! This function will remove any option that is named after a plugin type e.g.: layers, controls, styles, interactions, components .
File
- modules/
openlayers_field/ src/ Plugin/ Source/ Field/ Field.php, line 149 - Source: Field.
Class
- Field
- Class Field.
Namespace
Drupal\openlayers_field\Plugin\Source\FieldCode
protected function getGeojsonFeatures() {
$features = array();
foreach ($this
->getOption('fields', array()) as $field) {
$feature = FALSE;
if (isset($field['geojson']) && !empty($field['geojson'])) {
$feature = json_decode($field['geojson'], TRUE);
$json = FALSE;
if (isset($field['wkt']) && !empty($field['wkt'])) {
geophp_load();
$geophp = \geoPHP::load($field['wkt'], 'wkt');
if (is_object($geophp)) {
$json = $geophp
->out('json');
}
}
else {
if (isset($field['address']) && !empty($field['address'])) {
$geocoder = geocoder($this
->getOption('geocoder_handler', 'google'), $field['address'], array(), $this
->getOption('geocoder_cache', 2));
if (is_object($geocoder)) {
$json = $geocoder
->out('json');
}
}
}
if ($feature) {
$features[] = $feature;
}
}
return $features;
}
}