Select to view content in your preferred language

Id task, spatial references and printing

4100
2
Jump to solution
01-19-2015 07:17 AM
AdrianMarsden
Regular Contributor II

OK - I have an ID task.  it pushes results into a HTML table and stores the returned geometries in an array and the HTML table has and extra "highlight" button that, well, highlights the feature into a graphics layer.

I have a draw tool bar that allows custom graphics to the same graphics layer.

However when I use printemplate way of printing the highlight graphics fail to print.  The user added graphics (remember, the same graphics layer) works.

I have context thingy on my user graphics layer, that allows edit, move etc. If I select the highlight graphic so that the resize handles appear and then print i get the resize handles but still not the graphic

So, what is different?  The only thing I can see is that my user added graphics are in the same projection as the map, 27700.

So, I specify that the results from the ID task should be in 27700 (they get returned in 4326) by adding

       var sr = new esri.SpatialReference(27700);

        identifyParams.spatialReference = sr

And yet the results still return in 4326!

So, two questions - 1) is by diagnostics likely to be correct, that the projectiion is at fault & 2) why don't the identifyParams stick?


Cheers


ACM

0 Kudos
1 Solution

Accepted Solutions
AdrianMarsden
Regular Contributor II

Ok, I have it working and going to answer my own post


What I learned -

  • Whatever I did the graphics layer was always 4326, despite what the map is in (27700 in my case)
  • If graphic items are added to a  graphics layer then if the projection is NOT the same as the map - it fails to print
  • The results of the ID task have no projection returned with them - or so it would appear
  • but changing the projection of the graphic object prior to adding it to the graphic layer works

                    idGeo.push(results.feature.geometry)
                    idGeo.spatialReference = inSR

This is my bit of code that takes the geometry of the ID features, one at a time, and adds them to an array - without the second line these would get added as 4326.  inSR is a pre-defined projection object matching my map (27700)  - when I later add the appropriate array item it adds as 27700 and prints.  All very odd.

View solution in original post

0 Kudos
2 Replies
AdrianMarsden
Regular Contributor II

OK a bit more digging and it appears the user graphics layer is reference 4326!  I tried modifyig its creation ths

        userGraphics = new esri.layers.GraphicsLayer({
            "id": "usergraphics",
            "spatialReference": msr
        });

But it appears that the GraphicsLayer object doesn't support a spatiaReference property!

0 Kudos
AdrianMarsden
Regular Contributor II

Ok, I have it working and going to answer my own post


What I learned -

  • Whatever I did the graphics layer was always 4326, despite what the map is in (27700 in my case)
  • If graphic items are added to a  graphics layer then if the projection is NOT the same as the map - it fails to print
  • The results of the ID task have no projection returned with them - or so it would appear
  • but changing the projection of the graphic object prior to adding it to the graphic layer works

                    idGeo.push(results.feature.geometry)
                    idGeo.spatialReference = inSR

This is my bit of code that takes the geometry of the ID features, one at a time, and adds them to an array - without the second line these would get added as 4326.  inSR is a pre-defined projection object matching my map (27700)  - when I later add the appropriate array item it adds as 27700 and prints.  All very odd.

0 Kudos