Select to view content in your preferred language

Project Graphics by Geometry Service Loosing Attributes of Point.

799
1
09-04-2013 05:22 AM
AnandKirti
Deactivated User
Hello All,

I have around 3000 Point which contains x,y, spatialReference,attributes{id:'329',owner:'me'}; These all Points are available with 1 WKID, now I want to Project these Points on map with Different WKID. eg: 4326 [points spatialef] to 102113 [Map spatialRef].

I'm able to Project these Points on Map By using taskParameter, GeometryService But Point Graphics on Map doesn't contain the attributes after Projection. Actually These attributes I've to use in when user will select the points on Map. Resuleted of Selection I'll change the graphic color of Pin and releated data presented on HTML page will get selected.

What I tried :
Actually  Geometry Doesn't contain Any Attribute While graphic contains attributes. So I extended 
dojo.extend(esri.geometry.Point, {
        attributes: null
    });

and set My Attributes to this with This Points Array i created taskParameter --> transformed to another wkid --> project these transformed points by GeometryService. checked outpoint OnProjectCOmplete have attributes null, undefiend.

Next time I created graphic array and tried to Project on Map but GeomteryService say Wkid is miss or some other error it give.


Please suggest some sloution.. I read somewhere that I can not transform Graphics and then project these graphics Is it true.

Thank
Anand
0 Kudos
1 Reply
JasonZou
Frequent Contributor
Try this. The code just presents an idea, and assumes you are using the non-AMD style. Otherwise, change it accordingly.

var geoms = dojo.array(graphics, function(aGraphic) { return aGraphic.geometry; });
geomService.project(geoms, function(geometries) {
  onProjectCompleteHandler(geometries, graphics);
});

function onProjectCompleteHandler(geometries, graphics) {
  dojo.array(graphics, function(aGraphic, idx) {
    aGraphic.setGeometry(geometries[idx]);
  });

  // graphics should contain the projected geometries, and their attributes.
}
0 Kudos