public function init($args) { parent::init($args); $baseURLs = $args['BASE_URL']; if (!is_array($baseURLs)) { $baseURLs = array($baseURLs); } foreach ($baseURLs as $baseURL) { // TODO find a better way to reuse JSON parsing code for ArcGIS-related data $url = $baseURL . '?' . http_build_query(array('f' => 'json')); $content = file_get_contents($url); $data = json_decode($content, true); // this is a tiled service if (isset($data['tileInfo'], $data['tileInfo']['lods'])) { $this->levelsOfDetail = $data['tileInfo']['lods']; $this->tiledLayer = $baseURL; } else { $this->dynamicLayers[] = $baseURL; } if (isset($data['spatialReference'], $data['spatialReference']['wkid'])) { $wkid = $data['spatialReference']['wkid']; $this->setMapProjection($wkid); } } }
protected function addPolygon(Placemark $placemark) { parent::addPolygon($placemark); $this->polygons[] = $placemark; }
public function addPolygon(Placemark $placemark) { parent::addPolygon($placemark); $rings = $placemark->getGeometry()->getRings(); $polyStrings = array(); foreach ($rings as $ring) { $polyString[] = '[' . $this->coordsToGoogleArray($ring->getPoints()) . ']'; } $multiPathString = implode(',', $polyString); $properties = array('paths: polypaths'); $style = $placemark->getStyle(); if ($style !== null) { if (($color = $style->getStyleForTypeAndParam(MapStyle::POLYGON, MapStyle::COLOR)) !== null) { $properties[] = 'strokeColor: "#' . htmlColorForColorString($color) . '"'; if (strlen($color) == 8) { $alphaHex = substr($color, 0, 2); $alpha = hexdec($alphaHex) / 256; $properties[] = 'strokeOpacity: ' . round($alpha, 2); } } if (($color = $style->getStyleForTypeAndParam(MapStyle::POLYGON, MapStyle::FILLCOLOR)) !== null) { $properties[] = 'fillColor: "#' . htmlColorForColorString($color) . '"'; if (strlen($color) == 8) { $alphaHex = substr($color, 0, 2); $alpha = hexdec($alphaHex) / 256; $properties[] = 'fillOpacity: ' . round($alpha, 2); } } if (($weight = $style->getStyleForTypeAndParam(MapStyle::POLYGON, MapStyle::WEIGHT)) !== null) { $properties[] = "strokeWeight: {$weight}"; } } $propString = implode(',', $properties); $this->polygons[] = <<<JS polypaths = [{$multiPathString}]; polygon = new google.maps.Polygon({{$propString}}); polygon.setMap(map); JS; }
public function addPolygon(Placemark $placemark) { parent::addPolygon($placemark); // no style support for now $collapsedRings = array(); $polygon = $placemark->getGeometry(); foreach ($polygon->getRings() as $ring) { $collapsedRings[] = $this->collapseAssociativePoints($ring->getPoints()); } $jsonParams = array('rings' => $collapsedRings, 'spatialReference' => array('wkid' => $this->mapProjection)); $json = json_encode($jsonParams); $this->polygons[] = array('___POLYGON_SPEC___' => $json); }