Select to view content in your preferred language

Load Local Shapefile with Symbology and Attributes

4330
24
07-14-2010 01:10 PM
by Anonymous User
Not applicable
Original User: tbrophy

All,
This is a question that I hope has been asked before:
Is there any way for my users to load a shapefile into my SFV while retaining the attributes and the symbology of the layer file?

I downloaded and am using �??Shape File Overlay for Sample Viewer�?� from the ArcGIS resource Center, submitted 3-4-2010 by �??HardWork�?�. It works great, but I need it go a step further.
//
Shape File Overlay for Sample Viewer
http://resources.esri.com/arcgisserver/apis/flex/index.cfm?fa=codeGalleryDetails&scriptID=16846
//

I really need the symbology and attributes to make it complete. Has anyone done this? Any suggestions would be incredibly appreciated!!!

I have 2 applications using Web Mercator & WGS84
Sample Flex Viewer: flexviewer-src-1.0.zip (Build 06.12.09)
agslib-1.2.swc
flex_sdk_3.2
Required Adobe Flash Player version 10

Attached are 2 sample shapefiles (and .lyr files) in both projections: (102100, 4326)
0 Kudos
24 Replies
BjornSvensson
Esri Regular Contributor
Do you know of a way to convert this �??on-the-fly�?�?


The Flex API doesn't directly convert features on-the-fly.  However, there are two ways of converting from one projection to another.

1) If it's between geographic and web mercator, use the WebMercatorUtil class http://help.arcgis.com/en/webapi/flex/apiref/index.html?com/esri/ags/utils/WebMercatorUtil.html&com/... to project the geometries.  This is all done client-side.

2) Use the GeometryService project method to project geometries between any coordinate system.  This will send the request to the server which will project it.

Note if using the 1.x API, the GeometryService took graphics, in 2.x it takes geometries instead.
0 Kudos
by Anonymous User
Not applicable
Original User: tbrophy


1) If it's between geographic and web mercator, use the WebMercatorUtil class http://help.arcgis.com/en/webapi/flex/apiref/index.html?com/esri/ags/utils/WebMercatorUtil.html&com/... to project the geometries. This is all done client-side.


Bjorn,
Thank you for the direction. I really appreciate it. I've been trying to get "WebMercatorUtil.geographicToWebMercator" into the ShapeFile_Overlay_PLP code from Ricky Gonzalez. Can you show me how this is done? I've been at it all morning. (I get in pretty early.)

I am using:
SFV: flexviewer-src-1.0.zip (Build 06.12.09)
agslib-1.2.swc
flex_sdk_3.2
Required Adobe Flash Player version 10

(We are switching server architecture and can't move to ArcGIS 10 or Flex 2.0 until early next year.)

Thanks for your help.
0 Kudos
leonardooletic
New Contributor
hi i downloaded the atached fzip and it returns me tha the zip file is invalid coul you send me the code to my personal email oletic@gmail.com, thanks a lot
0 Kudos
by Anonymous User
Not applicable
Original User: coomsie

Hi,

thanks for the code,

I've quickly converted to the SFV 2.0 Beta 2, if anyone wants it.

I've included the compiled version and source code.

DISCLAIMER: A quick modify of the existing widget to bring it up to flex 2.0, code by others ....

p.s. it would be interesting to extend this to have the same graphics colors etc control as the advanced graphic widget in sfv 1.3 (we have one for SFV 2.0 - using flex 2.0 api) and have the ability to push the graphic (which is now geometry) into a feature layer as a new edit feature ... 🙂 

Anyone thinking of doing that?

Cheers
Coomsie

Attached is a modified version of the shapefile overlay widget that allows you to modify the symbology, displays the first attribute and supports points, lines and polygons.  You will need to have the original shapefile widget installed and update with the attached files. 

Let me know if this works for you.  If it does, I can post it to the code gallery.

DISCLAIMER: An intern in my group modified the widget, so I didn't write the code.
0 Kudos
ThomasBrophy
New Contributor III
Attached is a modified version of the shapefile overlay widget that allows you to modify the symbology, displays the first attribute and supports points, lines and polygons. You will need to have the original shapefile widget installed and update with the attached files.

Let me know if this works for you. If it does, I can post it to the code gallery.

DISCLAIMER: An intern in my group modified the widget, so I didn't write the code.


Mr. Gonzalez,
I've tested your PLP version of the ShpOverlay and it works great for polygon shps in both WGS84 and Web Mercator flex applications. (SFV 1.0)

I did come across a point location error in a WGS84 the application. (It works fine for my Web Mercator app.) Have you tested the correctness of the point locations for a point shapefile input? (I did not test a line shapefile.) The points are all pulled towards the center of the map 0, 0 anywhere from 20 - 70 miles. Please let me know what you come up with.

Have you given any thought to:

- Allowing the user to choose the label field?
- Display using a color ramp for multi - feature polygon?
- A place in the code to convert projection?  ie. Input shapefile WGS84 (4326) - Output projected graphic of shapefile in Web Mercator (102003) application.

Thank you again for hard work on the PLP version you posted.
0 Kudos
by Anonymous User
Not applicable
Original User: tbrophy

Have you tested the correctness of the point locations for a point shapefile input? (I did not test a line shapefile.) The points are all pulled towards the center of the map 0, 0 anywhere from 20 - 70 miles.


I just figured out what is going on:
The offset of the graphic points generated by our tool was so random that I was curious about their LAT LONGs.  I was right, each graphic point was right to the whole number.  If the point was -85.9495, 33.6794, the graphic point would be located at -85.00, 33.00.  And the reason it works perfectly for Web Mercator is that it uses whole numbers in meters.

I hope this helps in your adjustments.
0 Kudos
by Anonymous User
Not applicable
Original User: rjgonzalez73



I did come across a point location error in a WGS84 the application. (It works fine for my Web Mercator app.) Have you tested the correctness of the point locations for a point shapefile input? (I did not test a line shapefile.) The points are all pulled towards the center of the map 0, 0 anywhere from 20 - 70 miles. Please let me know what you come up with.


As I indicated in my original post, I didn't write the code so I didn't do any testing.  I haven't really looked at the code in depth to support it or add additional functionality.  I just posted the code since people were asking for the functionality and I knew it would be useful.  Once my environment has been upgraded to API version 2.0, I will revisit this widget and see if I can include some of the changes you requested.
0 Kudos
EjayLai
New Contributor II
That's great! I have issue with opening the file. It says 'it's not a valid zip file'. Any one has the same issue at all or I missed something?

Thanks.


Hi,

thanks for the code,

I've quickly converted to the SFV 2.0 Beta 2, if anyone wants it.

I've included the compiled version and source code.

DISCLAIMER: A quick modify of the existing widget to bring it up to flex 2.0, code by others ....

p.s. it would be interesting to extend this to have the same graphics colors etc control as the advanced graphic widget in sfv 1.3 (we have one for SFV 2.0 - using flex 2.0 api) and have the ability to push the graphic (which is now geometry) into a feature layer as a new edit feature ... 🙂 

Anyone thinking of doing that?

Cheers
Coomsie
0 Kudos
by Anonymous User
Not applicable
Original User: millsa

Mr. Gonzalez,
I've tested your PLP version of the ShpOverlay and it works great for polygon shps in both WGS84 and Web Mercator flex applications. (SFV 1.0)


Hi Thomas,

How did you get the widget to re-project in your Web Mercator application?

Also, to fix the point issue in your WGS84 widget, change the following in "ShpPoint.as":
        private var xcoor:Number;

        private var ycoor:Number;

        public function ShpPoint(xco:Number, yco:Number)

thanks,
-Adam
0 Kudos
IainCampion
New Contributor III
Hi,

it need the file to be a zip one currently,

i.e.

a normal zip file with all the normal gis file within it.

+ *.dbf
+ *.shp
+ *.shx


you could change the code to look for the files unzipped.




That's great! I have issue with opening the file. It says 'it's not a valid zip file'. Any one has the same issue at all or I missed something?

Thanks.
0 Kudos