Select to view content in your preferred language

Map XY  data from Excel into Flex

3919
26
Jump to solution
05-28-2012 08:58 PM
ShwetaMorkhandikar
Deactivated User
I have the excel file with X Y location, i need to map these dynamically onto Flex API. I am using Flex API 2.5
Tags (2)
0 Kudos
26 Replies
AnthonyGiles
Honored Contributor
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
0 Kudos
ShwetaMorkhandikar
Deactivated User
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


Thank you so much Anthony.
0 Kudos
AnthonyGiles
Honored Contributor
ShewtaM,

Please don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:

[ATTACH=CONFIG]15136[/ATTACH]

Regards

Anthony
0 Kudos
ShwetaMorkhandikar
Deactivated User
I tried using this in my Flex viewer and it's works wonderfully.
0 Kudos
AnthonyGiles
Honored Contributor
Shweta,

Please don't forget to also mark the thread as answered (the tick on the thread with the answer)

Regards

Anthony
0 Kudos
parvazparvaz
Occasional Contributor
Hi
Any solution for changing Excell coordinate to web map application projection system? for example my map has 102100 WKID but my coordinate has 3546 WKID. in your widget I should change my excell coordinate to my web, that this is not user friendly.
Regards
A.ponker
0 Kudos
AnthonyGiles
Honored Contributor
Parvaz,

Sorry but I have no intention of writing the code to perform any projection of the coordinates. I have supplied the source code if you want to develop the widget further but at the moment it meets my needs and I do not have the time to spend developing it.

If you do not have the ability to write flex code you could always look at doing the conversion in excel have a look at something like this http://www.dartmouth.edu/~renshaw/geogtools/ or the attached .xls file

Regards

Anthony
0 Kudos
PascalDionne
New Contributor
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
0 Kudos
anjelinaponker
Emerging Contributor
Hi
How can I use this code?
Regards
Anjelina
0 Kudos
anjelinaponker
Emerging Contributor
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



Hi
How can I use this code? can you send your Widget source code?
Regards
Anjelina
0 Kudos