Tuesday, September 9, 2008

Custom Symbol for Graphic using Flex API for ArcGIS

This is demonstration of a very simple custom symbol to render a graphic component on a map. Here is the application:

<?xml version="1.0" encoding="utf-8"?>
<esri:MapPoint x="45" y="45"/>

And here is the CustomSymbol:

package com.esri.test
import com.esri.ags.Graphic;
import com.esri.ags.Map;
import com.esri.ags.esri_internal;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.symbol.Symbol;

use namespace esri_internal;

public class CustomSymbol extends Symbol
public function CustomSymbol()

override esri_internal function drawGraphic(
map : Map,
graphic : Graphic
) : void
if( graphic.geometry is MapPoint )
drawMapPoint( map, graphic, MapPoint( graphic.geometry ));

private function drawMapPoint(
map : Map,
graphic : Graphic,
mapPoint : MapPoint
) : void
graphic.x = map.mapToContainerX(mapPoint.x);
graphic.y = map.mapToContainerY(mapPoint.y);

graphic.graphics.beginFill( 0xFF0000, 0.5 );
graphic.graphics.drawCircle( 0, 0, 10 );


Be warned - this uses an esri_internal function that is subject to change without notice :-(


Prem said...

How is this different from using the inforenderer property of a graphic to assign a new infosymbol to it?

Unknown said...

Sorry for the delay - there is no difference - the display of graphic is invalidated upon a new symbol or is a property of s symbol (infoRenderer in this case) changes :-)

Prem said...

ok Thanks thats great to know I was just trying to make sure that theres not one right way or better way to do it.

Unknown said...


I'm getting "Method marked override must override another method" on "override esri_internal"I'm sure I'm missing something.

Unknown said...
This comment has been removed by the author.
Unknown said...

If you are using the new 1.1 version - use the toScreenX(map, mapX) and toScreenY(map, mapY) :-)