DreamingWell Logo

Displaying a Shapefile (.shp) on a Map in Flex

Posted by Travis Collins at June 18, 2008 04:33 PM

Using some of my previously covered material, I have created a Flex appication that displays Shapefile (.shp) polygons on a map. This demo includes three different shapefiles that give some information about Brazos County, TX. You'll notice that you can interact with the polygons, change the 'Tile Provider' (yahoo, google, microsoft, etc) and change the dataset (shapefile). The demo also includes a DBF parser to display associated text data with each polygon.

Running Demo

Source Code

ModestMaps Project (Required)

This project makes use of ModestMaps and Vanrijkom's Flashlibs to parse the shapefile and DBF file into objects.

This demo is the beginning of an alternative to ILOG Elixr Maps. However, ILOG's maps come with a wonderful tool that simplifies and converts mapping data to an action-script class. As an alternative, you could use MapShaper.org to simplify your shapefiles into a reasonable dataset for parsing in Flex.

You can find tons of Shapefile data sets at ESRI's Arc Data Repository or GeographyNetwork.com.

I look forward to seeing how the community puts this to use.

 

Trackback Pings

TrackBack URL for this entry:
http://www.dreamingwell.com/cgi-bin/mt-tb.cgi/17

Comments

hello great job thx a lot :)
im writing a aplication based on Yours.
But I must place all Your xmlm code to as file.
I have done this, the shp file load propertly, the modest map provider centers the map, but.. the shapes doesent draw.
While debuging a I have a this kind of error:
Error #1009: Cannot access a property or method of a null object reference.
at com.modestmaps.flex::Map/addMarker()[C:\Documents and Settings\Travis Collins\My Documents\Flex Builder 3\ModestMap\com\modestmaps\flex\Map.as:353]
at ShapefileExplore/shapefileURLLoaderComplete()[C:\Documents and Settings\KChmie01\My Documents\Flex Builder 3\Projekt\src\ShapefileExplore.as:203]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


Can You help me??
best Regards Kriss :)

Comment by Kriss at July 25, 2008 04:40 AM


Hi its me again :)
this error I've mantioned befor is dysplaying when program gose to:
modestMap.addMarker(new Location(polygon.box.y,polygon.box.x),newMapPolygon);

in shapefileURLLoaderComplete(event:Event) function.

Comment by Kriss at July 25, 2008 04:59 AM


Post a comment




Remember Me?


Twitter Status

Travis flying into LAX today for #AdobeMax through Wednesday.

Last Seen in

Reston, Virginia

 

Privacy Policy

|

Copyright DreamingWell.com 2008