Пример #1
0
 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);
 }
Пример #2
0
 public function addPath($placemark)
 {
     parent::addPath($placemark);
     $pointArr = array();
     foreach ($placemark->getGeometry()->getPoints() as $point) {
         $pointArr[] = array($point['lat'], $point['lon']);
     }
     $polyline = Polyline::encodeFromArray($pointArr);
     $style = $placemark->getStyle();
     if ($style === null) {
         // color can be 0xRRGGBB or
         // {black, brown, green, purple, yellow, blue, gray, orange, red, white}
         $styleArgs = array('color:red');
     } else {
         $styleArgs = array();
         $color = $style->getStyleForTypeAndParam(MapStyle::LINE, MapStyle::COLOR);
         if ($color) {
             $styleArgs[] = 'color:0x' . htmlColorForColorString($color);
         }
         $weight = $style->getStyleForTypeAndParam(MapStyle::LINE, MapStyle::WEIGHT);
         if ($weight) {
             $styleArgs[] = 'weight:' . $weight;
         }
     }
     $this->paths[] = implode('|', $styleArgs) . '|enc:' . $polyline;
 }
Пример #3
0
 public function setMapProjection($proj)
 {
     if (!$proj) {
         return;
     }
     parent::setMapProjection($proj);
     //$this->mapProjection = $proj;
     $this->unitsPerMeter = null;
     // arbitrarily set initial bounding box to the center (1/10)^2 of the containing map
     $bbox = $this->wmsParser->getBBoxForProjection($this->mapProjection);
     $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 = oldPixelZoomLevelForScale($this->getCurrentScale());
     $this->center = array('lat' => ($this->bbox['ymin'] + $this->bbox['ymax']) / 2, 'lon' => ($this->bbox['xmin'] + $this->bbox['xmax']) / 2);
 }
Пример #4
0
 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();
 }
 public function setCenter($center) {
     $newCenter = $this->mapProjector->projectPoint($center);
     parent::setCenter($newCenter);
 }