Skip to content

Instantly share code, notes, and snippets.

@gordonbanderson
Created April 3, 2013 07:30
Show Gist options
  • Save gordonbanderson/5299125 to your computer and use it in GitHub Desktop.
Save gordonbanderson/5299125 to your computer and use it in GitHub Desktop.
Example of drawing a red/green/blue triangle around a given map coordinate
/*
Render a triangle around the provided lat,lon, zoom from the editing functions,
*/
public function MapWithLines() {
$map = $this->owner->getRenderableMap();
$map->setZoom( $this->ZoomLevel );
$map->setAdditionalCSSClasses( 'fullWidthMap' );
$map->setShowInlineMapDivStyle( true );
$scale = 0.3;
// draw a triangle
$point1 = array(
$this->Lat - 0.5*$scale, $this->Lon
);
$point2 = array(
$this->Lat + 0.5*$scale, $this->Lon-0.7*$scale
);
$point3 = array(
$this->Lat + 0.5*$scale, $this->Lon+0.7*$scale
);
$map->addLine( $point1, $point2 );
$map->addLine( $point2, $point3, '#000077' );
$map->addLine( $point3, $point1, '#007700' );
return $map;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment