You are here

function _gm3_field_get_array_from_poly_string in Google Maps API V3 7

Helper function to get values from a polygon/polyline/rectangle string

1 call to _gm3_field_get_array_from_poly_string()
gm3_field_field_insert in gm3_field/gm3_field.module
Implementation of hook_field_insert().

File

gm3_field/gm3_field.module, line 274

Code

function _gm3_field_get_array_from_poly_string($value, &$items, $poly_type, $type = FALSE) {
  if (is_array($value) || strlen(trim($value))) {
    if (is_string($value)) {
      $value = preg_split("/\n/", $value);
    }
    foreach ($value as $poly) {
      $item = array(
        $poly_type => $poly,
      );
      if ($type) {
        $item['gm3_type'] = $poly_type;
      }
      $items[] = $item;
    }
  }
}