/** * {@inheritdoc} */ public function getJS() { $js = parent::getJS(); $js['opt']['url'] = file_create_url(drupal_get_path('module', 'openlayers_examples') . '/assets/Butterfly.png'); return $js; }
/** * {@inheritdoc} */ public function getJS() { // Ensure the options are properly set and clean. $this->options['dataType'] = array_filter($this->options['dataType']); $this->options['typeOfFeature'] = array_filter($this->options['typeOfFeature']); $this->options['actionFeature'] = array_filter($this->options['actionFeature']); // Process initial data. Ensure it's WKT. if (isset($this->options['initialData'])) { // Process strings and arrays likewise. geophp_load(); if (!is_array($this->options['initialData'])) { $this->options['initialData'] = array($this->options['initialData']); } $geoms = array(); foreach ($this->options['initialData'] as $delta => $item) { if (is_array($item) && array_key_exists('geom', $item)) { $geoms[] = geoPHP::load($item['geom']); } else { // Is this really necessary ? Commented for now. // $geoms[] = geoPHP::load(''); } } $combined_geom = geoPHP::geometryReduce($geoms); // If we could parse the geom process further. if ($combined_geom && !$combined_geom->isEmpty()) { // We want to force the combined_geom into a geometryCollection. $geom_type = $combined_geom->geometryType(); if ($geom_type == 'MultiPolygon' || $geom_type == 'MultiLineString' || $geom_type == 'MultiPoint') { $combined_geom = new \GeometryCollection($combined_geom->getComponents()); } // Ensure proper initial data in the textarea / hidden field. $this->options['initialData'] = $combined_geom->out(strtolower(key($this->options['dataType']))); $this->options['initialDataType'] = key($this->options['dataType']); } else { // Set initial data to NULL if the data couldn't be evaluated. $this->options['initialData'] = NULL; $this->options['initialDataType'] = key($this->options['dataType']); } } return parent::getJS(); }