public function init($args) { parent::init($args); $this->baseURL = $args['BASE_URL']; // TODO find a better way to reuse JSON parsing code for ArcGIS-related data $url = $this->baseURL . '?' . http_build_query(array('f' => 'json')); $content = file_get_contents($url); $data = json_decode($content, true); if (isset($data['spatialReference'], $data['spatialReference']['wkid'])) { $this->setMapProjection($data['spatialReference']['wkid']); } $this->unitsPerMeter = self::getScaleForEsriUnits($data['units']); if (isset($data['supportedImageFormatTypes'])) { $this->supportedImageFormats = $data['supportedImageFormatTypes']; } foreach ($data['layers'] as $layerData) { $id = $layerData['id']; $this->availableLayers[] = $id; } $this->enableAllLayers(); $bbox = $data['initialExtent']; unset($bbox['spatialReference']); $xrange = $bbox['xmax'] - $bbox['xmin']; $yrange = $bbox['ymax'] - $bbox['ymin']; $bbox['xmin'] += 0.4 * $xrange; $bbox['xmax'] -= 0.4 * $xrange; $bbox['ymin'] += 0.4 * $yrange; $bbox['ymax'] -= 0.4 * $yrange; $this->bbox = $bbox; $this->zoomLevel = $this->zoomLevelForScale($this->getCurrentScale()); $this->center = array('lat' => ($this->bbox['ymin'] + $this->bbox['ymax']) / 2, 'lon' => ($this->bbox['xmin'] + $this->bbox['xmax']) / 2); }
public function init($args) { parent::init($args); $this->baseURL = $args['BASE_URL']; // TODO find a better way to reuse JSON parsing code for ArcGIS-related data $url = $this->baseURL . '?' . http_build_query(array('f' => 'json')); $content = file_get_contents($url); $data = json_decode($content, true); if (isset($data['spatialReference'], $data['spatialReference']['wkid'])) { $this->setMapProjection($data['spatialReference']['wkid']); } if (isset($data['supportedImageFormatTypes'])) { $this->supportedImageFormats = $data['supportedImageFormatTypes']; } foreach ($data['layers'] as $layerData) { $id = $layerData['id']; $this->availableLayers[] = $id; } $this->enableAllLayers(); }