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; }
protected function addPolygon(Placemark $placemark) { parent::addPolygon($placemark); $this->polygons[] = $placemark; }
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); }