public function addPoint(Placemark $placemark) { parent::addPoint($placemark); $geometry = $placemark->getGeometry(); $coord = $geometry->getCenterCoordinate(); if (isset($this->mapProjector)) { $coord = $this->mapProjector->projectPoint($coord); } // http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerOptions $options = ''; $style = $placemark->getStyle(); if ($style) { if (($icon = $style->getStyleForTypeAndParam(MapStyle::POINT, MapStyle::ICON)) != null) { $options .= "icon: '{$icon}',\n"; } } $fields = $placemark->getFields(); if ($fields && isset($fields['description'])) { // TODO truncate overly long descriptions $subtitle = $fields['description']; } else { $subtitle = $placemark->getSubtitle(); } if (!$subtitle) { $subtitle = ''; // "null" will show up on screen } $values = array('___IDENTIFIER___' => count($this->markers), '___LATITUDE___' => $coord['lat'], '___LONGITUDE___' => $coord['lon'], '___TITLE___' => json_encode($placemark->getTitle()), '___OPTIONS___' => $options, '___SUBTITLE___' => json_encode($subtitle)); $this->markers[] = $values; }
public function addPoint(Placemark $placemark) { parent::addPoint($placemark); $point = $placemark->getGeometry()->getCenterCoordinate(); $style = $placemark->getStyle(); // defaults $templateValues = array('___SYMBOL_TYPE___' => 'SimpleMarkerSymbol'); if ($style !== null) { // two ways to style markers: if (($icon = $style->getStyleForTypeAndParam(MapStyle::POINT, MapStyle::ICON)) !== null) { // 1. icon image // http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jsapi/picturemarkersymbol.htm $templateValues = array('___SYMBOL_TYPE___' => 'PictureMarkerSymbol', '___SYMBOL_ARGS___' => '"' . $icon . '",20,20'); // TODO allow size (20, 20) above to be set } else { // 2. either all four of (color, size, outline, style) are set or zero // http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jsapi/simplemarkersymbol.htm $color = $style->getStyleForTypeAndParam(MapStyle::POINT, MapStyle::COLOR); if ($color) { $color = htmlColorForColorString($color); } else { $color = 'FF0000'; } $size = $style->getStyleForTypeAndParam(MapStyle::POINT, MapStyle::SIZE) or $size = 12; // TODO there isn't yet a good way to get valid values for this from outside $shape = $style->getStyleForTypeAndParam(MapStyle::POINT, MapStyle::SHAPE) or $shape = 'esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE'; $templateValues['___SYMBOL_ARGS___'] = "{$shape},{$size},new esri.symbol.SimpleLineSymbol(),new dojo.Color(\"#{$color}\")"; } } if (isset($this->mapProjector)) { $point = $this->mapProjector->projectPoint($point); list($x, $y) = MapProjector::getXYFromPoint($point); $templateValues['___X___'] = $x; $templateValues['___Y___'] = $y; } else { // TODO this might be reversed // if it is then we can get rid of some code $templateValues['___X___'] = $point['lat']; $templateValues['___Y___'] = $point['lon']; } // TODO use $placemark->getFields to populate Attributes $templateValues['___TITLE___'] = $placemark->getTitle(); $subtitle = $placemark->getSubtitle(); $templateValues['___DESCRIPTION___'] = $subtitle ? $subtitle : ""; $templateValues['___IDENTIFIER___'] = count($this->markers); $this->markers[] = $templateValues; }
protected function addPoint(Placemark $placemark) { parent::addPoint($placemark); $this->markers[] = $placemark; }