function leaflet_widget_geojson_feature in Leaflet Widget for Geofield 7.2
Same name and namespace in other branches
- 7 leaflet_widget.module \leaflet_widget_geojson_feature()
Creates a geoJSON feature from a geofield geom value.
Parameters
string $geom: Well known text value.
array $properties: Properties for the geoJSON feature.
string|NULL $geom_type: The geometry type the geometry data are given. Set to NULL to use autodetect. It's recommended to define the type to speed up processing.
Return value
array|bool Returns a geoJSON feature or FALSE on failure.
1 call to leaflet_widget_geojson_feature()
- leaflet_widget_widget_prepare_items in ./
leaflet_widget.module - Prepares the field items - return a geoJSON FeatureCollection.
File
- ./
leaflet_widget.module, line 390 - Leaflet widget module for Geofield.
Code
function leaflet_widget_geojson_feature($geom, $properties = array(), $geom_type = 'wkt') {
$geophp = geophp_load();
if (!$geophp) {
return FALSE;
}
$geometry = geoPHP::load($geom, $geom_type);
// Avoid notice on error.
if (!$geometry) {
return FALSE;
}
return array(
'type' => 'Feature',
'geometry' => json_decode($geometry
->out('json')),
'properties' => $properties,
);
}