Polygon and Geodetic Circle Draw Tool
In this sample, I'm demonstrating how to roll you own draw tool using the Flex API for ArcGISServer. I'm attaching mouse listeners to the map and based on the selected tool, I'm drawing a polyline, a circle or a geodetic circle. For the latter, I'm using the undocumented (subject to changes)
ProjUtils class to enable me to calculate the distance in meters between two lat/lon values. In addition, this class has the capability to calculate a lat/lon value for a given lat/lon origin, radius and azimuth. When using this sample, watch out for boundary condition (too close to the poles or crossing the date line) as this is a very simple implementation. How to handle these conditions will be another post :-) as usual, you can download the source from here. Have fun, and hope to see some of you at MAX next week.
Comments
Why if I use draw circle and when i zoom in or zoom out the size of this circle isn't change.Not like if I use geodetic...
Regars,
Gus Leo
is used. would appreciate some advice on this?
for example what do i do to draw a circle with a radius of 5 km?
i have a few more questions,
you have used sprite.graphics.lineTo()
while in this example (http://arcgis.myclearwater.com/police/callsforservice)the polygon.addRing() method from the package com.esri.ags.geometry is used, what is the difference between the two?
im a newbie in gis/flex programming, so my questions might be naive. what i wanted to know is that what is the difference between these two approaches if we consider the GIS functionality like query tasks etc.
why not use the graphics functionality provided by flex Graphics class?
private var ts:TextSymbol = new TextSymbol("Testing",null,0x0000FF);
private var m_txtGraphics:Graphics;
.
.
.
m_txtGraphics = new Graphics(m_circleGeometry.center,ts);
graphicsLayer.add(m_txtGraphics);
but after executing the code when i zoom-in and zoom-out the map, the size of text should be changed accordingly like geodetic circles ... what should i do???
Also i want to know, from where it is calling draw method of GeodeticSymbol?
2 - In your main app, create MyCircleSymbol instance where u set different property values.
3 - To each "tool" - u can assign a previously created symbol dynamically - that will be associated with the generated graphic.
4 - We call the draw routine at the right time whenever the refresh function is invoked - to be more precise - refresh invalidates the display list - and draw is called in the update display list function.
while( ang < Maths.PI/4 )
{
ang += Utils.PI_OVER_180;
Utils.geodeticDirect( origPoint, circleGeometry.radius, ang, Utils.EARTH_RADIUS_IN_METERS, tempPoint );
sx = toScreenX( map, tempPoint.x * Utils.ONE_EIGHTY_OVER_PI );
sy = toScreenY( map, tempPoint.y * Utils.ONE_EIGHTY_OVER_PI );
sprite.graphics.lineTo( sx, sy );
}
Instead of drawing an arc of 45 degree, its draws semi circle ... But i don't want radii lines with the curve.
I am new to this technology,can u tell me how to go about it