Solved! Go to Solution.
ShwetaM
Attached is a zip file containing both the compiled and uncompiled code. All you should need is an excel file that has a minimum of two columns one holding your x coords and the other your y coords (in the same spatial reference as your base map). All other columns will come across as attributes. In the config xml specify the column names used for your coords and a title field if required.
Place the images under assets in your assets/images folder.
Regards
Anthony
Hi Parvaz,
I developped a widget that is doing what you want. It reads a CSV file that contains two columns with coordinates x and y. It can be in any coordinate system. The coordinate system is identified by the user through a combox box before the file is read and parsed. The parsing result is push into an array and for every record a MapPoint is created and projected on the map. Here are some code elements:
var outSR:SpatialReference = new SpatialReference(wkid.selectedItem.data);
for (var i:int = 0; i < donnees.length; i++)
{
var X:Number = donnees[abs];
var Y:Number = donnees[ord];
var point:MapPoint = new MapPoint(X, Y, outSR);
geometryService.project([point as Geometry], new SpatialReference(32198));
}
private function handlerProjectComplete(e:GeometryServiceEvent):void
{
if (incremente < donnees.length)
{
var pt:MapPoint = (e.result as Array)[0] as MapPoint;
var myGraphic : Graphic = new Graphic();
myGraphic.geometry = pt;
myGraphic.symbol = graphicPointSym;
myGraphic.addEventListener(MouseEvent.MOUSE_OVER, handlerMouseRollOver);
graphicsLayer.add(myGraphic);
donnees[incremente].push(myGraphic); points.push(myGraphic);
incremente++;
}
The comboxBox dataProvider comes from this list that link the wkid number to project in the map's projection:
private const projectionList:ArrayCollection = new ArrayCollection(
[
{ data: 4326, label: "Géographique WGS84" },
{ data: 4269, label: "Géographique NAD83" },
{ data: 102113, label: "Web_Mercator WGS84 (Google)" }, /* Use 102100 instead */
{ data: 26917, label:"UTM fuseau 17N NAD_1983" },
{ data: 26918, label:"UTM fuseau 18N NAD_1983" },
{ data: 26919, label:"UTM fuseau 19N NAD_1983" },
{ data: 26920, label:"UTM fuseau 20N NAD_1983" },
{ data: 26921, label:"UTM fuseau 21N NAD_1983" },
{ data: 32183, label:"MTM fuseau 3 NAD_1983" },
{ data: 32184, label:"MTM fuseau 4 NAD_1983" },
{ data: 32185, label:"MTM fuseau 5 NAD_1983" },
{ data: 32186, label:"MTM fuseau 6 NAD_1983" },
{ data: 32187, label:"MTM fuseau 7 NAD_1983" },
{ data: 32188, label:"MTM fuseau 8 NAD_1983" },
{ data: 32189, label:"MTM fuseau 9 NAD_1983" },
{ data: 32190, label:"MTM fuseau 10 NAD_1983" },
{ data: 32198, label: "Lambert conique conforme - Québec" }
]);
Hope that helped.
pdio