2012 Developer Resolutions: Melting faces!

It’s that time of year again, 2011 is coming to an end and I start wondering where the hell the time went. Looking back at my 2011 resolutions, I didn’t get as much done as I would like, but I like to think I accomplished quite a bit. I’ve been doing a lot of Node.js experimenting and I’ve gotten pretty good at CoffeeScript. I’m a better Ruby dev today than I was a year ago. My Python skills are about the same, but I’ve gotten more familiar with Django. I’ve learned some more native mobile, but have not had a chance to use it in production yet. My design skills could still use some help.

I plan on forming my goals as this post at tutsplus suggest. So, for 2012, I’m trying to focus my goals a bit more.

  • Node.js. I’m really enjoying the stuff I’ve been doing so far and I look forward to really getting to use Node in production applications. Couple this with CoffeeScript, and expanding my C/C++ skills and I hope to really become proficient with Node.
  • Ruby. This includes, Rails and Sinatra. I’ve gotten pretty good here, but I can be better.
  • Silverlight. I know, wtf right? Well, I actually have some opportunities that require I at least get good with Silverlight. I figure this also help out with my WP7 skills. Not a huge goal for 2012, but at least the beginning of the year.
  • Mobile. Still on the list. I have a couple of opportunities here, so will put some focus into this area.

I also plan to improve myself as a well rounded developer. I have Mastering Algorithms in C, and plan on finishing that up along with some more books like it. My degree is not in computer science, but I don’t want that to hold me back.

For kicks, I’m also going to be trying my hand at some Lisp. I have Land of Lisp sitting on my bookshelf unread, so what choice do I have right?

I’m still actively pursuing freelance work as well, and so far it looks like I’ll be starting 2012 off with some work under my belt. Looking forward to it.

These goals are tentative. Chances are, I’ll get sidetracked by something that piques my interests. For all I know, I could end up praising Prolog by the end of 2012.

 

ESRI-JSON to GeoJSON, with Node.js

I’ll admit, my professional GIS development experience is in the ESRI sphere. It’s what we use at work and it’s what I’ve been using for going on 10 years now. I’m familiar with FOSS4G, but have not really had the opportunity to develop any projects incorporating it. Because of this, I was not really aware that the ESRI REST spec for their JSON response really differed much from the standard GeoJSON spec. My naivety is a little embarrassing as a GIS professional.

So my interest was piqued a few days ago when I saw someone post a tweet about the request to have ESRI add a GeoJSON response to their REST API. For whatever reason, I got it on my head that it couldn’t be that hard to do. A quick Google search showed their were a couple of ways to do this with third party tools, but I figured there had to be a way to do this quickly in the browser or natively server side.

Recently, I have been practicing on little projects in various languages and frameworks and I thought Node.js would be a great solution to get this rolling. It’s fast, can work with JSON objects natively and should work pretty simple without having to worry about browser compatibility issues because it runs through Google’s V8 engine.

So I set out looking at what would need to be done to convert ESRI-JSON to GeoJSON. As an aside, this entire project was done inside Google Chrome using the Cloud9 IDE and deployed directly to Heroku from within Cloud9. I could probably do a whole write up on that experience.

It took me a couple of days and lots of debugging and running various ESRI-JSON through the converter, but I think I’ve got a very usable application running to demonstrate the conversion. If you’ve worked with this before, GeoJSON has a standard array called “coordinates” to hold x,y information. ESRI-JSON uses “rings” for polygons, “paths” for lines and just an array of x,y pairs for points. A little annoying to convert, but not a big deal.

ESRI-JSON to GeoJSON Converter

You can also send your ESRI-JSON as a parameter to http://esritogeo.herokuapp.com/parse/esrijosngoeshere and get a JSON response. I should point out a caveat is that you need to make sure you are sending the correct projected data. GeoJSON uses standard Lat/Long, so your ESRI-JSON should be in Spatial Reference 4326.

I put a couple of demo pages up. This sample uses the ESRI JavaScript API to load a FeatureLayer of points. This sample uses Leaflet to load the GeoJSON that was converted. The GeoJSON sample takes a few seconds to load and would not load in IE8 for me, but worked in Chrome. I don’t know if this is an issue with Leaflet or not, sorry.

The ESRI-JSON to GeoJSON application is on Heroku for now as an experiment. I don’t have any permanent Node.js hosting. So if it gets a lot of traffic it may just disappear. Heroku is for quick testing, not production. I don’t really have funds to put this up for wide use. I will get the whole application up on Github, as soon as I figure out how from within Cloud9.

I would however like to share the code that does the conversion, which is shown below.

I’m sure this functionality could be incorporated using Server Object Extensions on ArcGIS Server, but it works so cleanly this way. Maybe some people will find this useful and could incorporate it into their workflows.

Thanks.

edit: Project is now available on github.

Node.js native extension with a hammer and a prayer

I get excited about dumb stuff when it comes to programming, so when I first heard about Node.js, it seemed so out there I was like, Ice Cream Ballz, I have to try this! I experimented, read the books, guides, online tutorials and decided, I am in, you got me.

When a good man goes to war

Node.js is built using the Google V8 Engine. For most people that use Node.js, this probably doesn’t matter to you at all. However, if you are interested in building native extensions to Node.js, you better learn to embrace it. The Node.js docs sort of cover a simple “Hello World” example of writing a native extension in C++. Then they link to the node_potsgres for an example of a real world project. This is like teaching a 5-year old how to drive a Tonka Truck, then giving him a big rig to drive around the block. Bless their hearts, but the node_postgres extension is 600+ lines of code and although well documented, unless you familiarize yourself with some V8 stuff and review the Node.js source, you may as well be reading a Celtic translation of lorem ipsum. Or maybe you’re just way smarter than me.

I decided at some point I wanted to build a native extension for Node.js using the ESRI C++ File Geodatabase API. I’ll write more details on this project at a later date when I can actually make it do something useful. For now, the point is I am a novice at C++ at best but very eager. I can struct, point and make, but I don’t work in C++ on a day-to-day basis. So I did what anyone else would do. I raised the mighty Goolgle hammer and I pounded out “Hello World” examples and nailed down some erroneous errors in my attempts.

WTF… I mean WAF

I did ok at first, knocking out some simple stuff. When I tried adding other libraries to a project was when I hit the first wall. Node.js uses WAF as it’s build system for native extensions. You write a wscript file and use the node-waf command. WAF as they state “… is provided for the ease of users”. Sure, I use WAF all the time, great, this should be easy (I have never heard of WAF before). Turns out, WAF is a Python framework for compiling, similar to ANT, Make, and Rake. So time to switch from C++ mode to automation mode. Turns out WAF is pretty cool, and you can pretty much just assign your flags to a build object and let it rip. I had a tough time figuring out how to define some environment variables, and the stuff in WAF book didn’t quite work as expected, but once I had wrapped my head around WAF, I felt like I had conquered a small country.

In search of the Node way…

When I got my first Node.js extension to compile, I was smiles ear to ear. It was a simple ext.speak(“Say my name”) and it would print “Say my name” in the console. But that did not seem like a non-blocking Node.js way of doing things. So I set off to figure out how to ride the callback train to crazy town. First, I attempted to replicate what was happening in the node-postgres project. They extend the EventEmitter which is part of Node.js and go from there. I still had trouble following as I had trouble figuring out if some functions came from the Node.js headers or the V8 headers. Then I came across this issue on the Node.js github page. That little comment was like a small spark as to how to handle an event in C++. Researching the EventEmitter lead me to an example on github called node-event-emitter that did exactly what I had been looking to do this entire time. It was the revelation I needed to continue. You don’t have to write your Node.js native extension to extend EventEmitter, just write the handlers in C++, then use JavaScript to create a shim to inherit EventEmitter and voila! Remember that feeling you got when you first learned how to read? Me neither, but I imagine this is how I would have felt. Just to illustrate, below is a generic example of a JavaScript shim copied from node-event-emitter.

On the Node to find out

So what the hell is point of all this rambling? Well, I think I shared some pretty good resources and really I wanted to highlight some of the stuff you will probably encounter if you attempt to write some Node.js native extensions. There are a couple of really good tutorials out there to write an extension and really it’s not that hard. My biggest stumbling block was trying to figure out how to write an asynchronous extension. There simply is not much guidance (that I could find) on how to accomplish this. Node.js is still very new and I have yet to see anything beyond a couple of blog posts on how to write native extensions. You won’t find this stuff in any of the Node.js books available (as far as I know, if there is a book that covers some of this, please let me know). Granted, I did not hit the google groups or an IRC, which admittedly may have lead to quicker results. But at least I was forced to read lots of source code, get more familiar with some V8 Engine stuff and learned me some C++ along the way. By the way, don’t attempt to learn C++ by diving into writing Node.js native extensions. Just my opinion, but maybe start with brisk walks before running a marathon.

In the end, I am well on my way to writing what I think could be a pretty cool Node.js native extension and if you want to check it out, you can find it here.

A really big thanks to Ben Noordhuis and his event-emitter example on github. Without that example, I’d be wallowing in a sea of google search inferno.

Again, since I am new to this, if I have misinterpreted anything or lack understanding on some stuff, please point it out. I’m here to learn and I’m taking names.

I posted on Google Plus for this too. Talk about recursive blogging.

Day in the life of a GIS Analyst (Developer)

An abbreviated version of a typical day involving the duties of a GIS Analyst and Developer. Or maybe it’s just me.

Hour 1

Arrive to work before the sun does. Grab some coffee, catch up on email. Peruse the latest ArcUser and ArcNews and look at how easy it all should be.

Hour 2

Crap, all the Arc licenses are in use. Send out mass email to all users asking if someone can free one up. Ok, you have a license. One of your SDE databases is down, a ticket to ESRI has been sent. Use an old slower SDE. Begin running a geoprocessing task on a couple million polygons.

Hour 3

More coffee. Discover some internal web applications are not working because that single SDE is down. Send out email to users notifying of situation. Development IDE of choice crashes or freezes a few times to remind you that you are a bad person.

Hour 4

ArcMap crashes in the middle of editing. Try again, crap, cashed again. Try this one more… forget it, no more editing, just use draw tools to make quick exhibits.

Hour 5

More coffee. Given a PDF map that came from a consultant and asked make changes. That’s it, just a PDF. You do things to make this happen that make you feel dirty.

Hour 6

Lunch time. Ninety-percent of solutions to GIS questions or development issues are found on web sites that are blocked as Social Media or Blogs. Twitter rant (vis smartphone). Check that geoprocessing task is still running.

Hour 7

Rush request for exhibit that needs data on the SDE that is down. That particular dataset can also be found on an external hard drive. The enclosure died last month. Pry open enclosure, rip out hard drive, pop open work pc and manually plug it in to extract the data. Cross your fingers that no one from IT department walks in as the internals of your gutted work machine are exposed.

Hour 8

Seriously reconsidering your life decisions.

Hour 9

Geoprocessing task failed around the 8-hour 5-minute mark with geometry errors. After 40 minutes is still cancelling itself. Go home and drink to forget.

Note: No actual analysis got done, as the failed geoprocessing task squashed that goal.

Knockout.js and why Flex devs should try it.

Being primarily a Flex developer at work, I take great pleasure in the opportunities I have at the workplace to use different technologies to get the job done. Recently, I developed a simple internal application that I could have done in Flex, but really, it was fairly straightforward and I wanted to brush up on my JavaScript skills, so I built the app using the ESRI JavaScript API. (Sorry, it’s an internal app, so I can’t really share, but trust me, it’s really simple).

So working with HTML/JavaScript, I was really trying to find a comfortable manner in which I could write my app in a way closer to what I was used to. I know some people have some very strong feelings about JavaScript and it’s evils.

But if you’re writing ActionScript, you’re already half-way there. I’m a big fan of frameworks and utilities when developing. The ESRI API uses, Dojo, which I have heard the JavaScript mention before was due to it’s rich API for working with web services. I’m not a huge fan of Dojo dijits, so like many I use jQuery for DOM specific manipulation or handling. Many times I found myself doing a lot of element.innerHTML = “blahblah” stuff, and it just felt a bit dirty. I know there are some very talented JavaScript/Web developers out there. I’m not really one of them (yet!).

As I began to clean up my HTML markup, using more CSS I sought out something that could help me tie my HTML to my data. That’s when I found Knockout.js. This is a great lightweight utility that utilizes a Model-View-View Model (MVVM) pattern to update your UI. I know this is the recommended pattern for use when developing Windows Phone 7 applications as well.

As I began to work with it, it felt very familiar and finally it hit me. It was just like Binding a Presentation Model to an MXML view in some Flex stuff I had done. I first used a presentation model when working with Swiz and it’s a nice way of binding Model data to your View and capturing View events. It’s not exactly the same, but the familiarity of it alone was enough to make using JavaScript enjoyable.

I put a sample page up here.

Let’s look at some of it.

Notice the ‘data-bind’ tag that I use. This would be similar to binding values in MXML via <s:comp text={‘bindableModel.value’}/>.

Then in my JavaScript, I define a viewModel with some attributes and even a method. When I started using stuff like  ’data-bind=”click: search’ which points to a function in my viewModel, that is when it all started to click for me. Now, I have bound my view to a method in the viewModel and that method can access other items in the viewModel to perform it’s task. I don’t need to find the value of a DOM element that may have been updated earlier or anything like that. This is a really simple example when you look at it, but I think it demonstrates some powerful features of Knockout.js. You can review how to use ko.observable and ko.observableArray in the Knockout.js documentation.

If you look at the JavaScript of the sample app, you could see that to update an observable, by simple calling viewModel.osmCopyURL(“myUrl”). The update to the model is automatically and seamlessly updated to the View. No need to use jQuery or search for DOM element by id. You can have a clean separation of your logic from your view.

I have barely scratched the surface of Knockout.js, but I would highly recommend that anyone looking to take on a new project using JavaScript check it out and definitely would recommend it to any Flex developers that are dabbling/transitioning to JavaScript, as I found it to be a great tool that provided familiar patterns and functionality.

 

Simple ArcObjects Tip for Joining Tables

I have recently been doing a lot of work on our server side functions using ESRI ArcObjects. I’m not what one might call an ArcObjects expert, and I know my way around some C# and .NET. Currently, if you want to learn ArcObjects, you need to wade through the online documentation, struggle with the search features and rummage over forum postings. The ArcObjects book lays a pretty good foundation, but is pretty outdated (it uses VB6 for examples), but with a little leg work, most devs could probably pick it up.

I thought I would share a cool little tip I learned while working with some large data. We have a parcel data set (ArcSDE) that has approximately 2 million features with unique id’s. I needed a function that would let us find a parcel quickly. That’s the easy part, but we also have a table in the SDE that has the detailed information for the parcel features, including addresses, land use and so forth. I also needed to return this information to a web application. This can be accomplished a couple of ways, you can build a relationship or you can do a join in the ArcGIS Server MapService via your mxd.

The classic table join slowed the service to a crawl. Even after applying tablur indexes. This is 2 million features after all. A relationship may also be a good choice and can be accessed via ArcObjects. I don’t have direct access to the SDE, and besides we update this data on an annual basis, so I don’t know if that also requires the relationships to be rebuilt on the SDE every time the Feature and other Table are updated. One of my goals when developing my server functions is to lessen the maintenance need of our IT group for our GIS data, so I wanted to try to figure out a way to do this kind of query on the fly and to do it quickly.

Up until now I had been using IQueryFilter to query features in my functions. This won’t let me do table joins though. Then I discovered the IQueryDef interface which will let you do table joins, and you use the where clause to define that join.

This looked just like what I needed. It worked ok, but it was still joining some 2 million records. At first I was defining my parcel query with a second IQueryFilter. Then it occurred to me that I could just find my feature with all the joined data by looking for it with IQueryDef.

This way the join only occurs on that single feature instead of 2 million features. This method is really quick now. For the record, we use WebOrb in-house for our server functions, and this allows me to use Remote Objects with the ESRI Flex API. This little function is proving to be a valuable resource in our current day-to-day use.

One other item that took me a while to figure out was how to get an IFeatureCursor out of the IQueryDef. I was able to do that in the following steps.

Once I do this, I use the IFeature with my .NET to Flex classes library to send a FeatureSet to my ESRI Flex Application.

So that is my ArcObjects tip of the day. There might be some better ways of performing this function or a quicker way of getting to the IFeatureCursor from IQueryDef. I am always open to some helpful tips. Maybe it’s common knowledge for seasoned ArcObjects devs, but I thought it was pretty cool.

NativeMappedSignal (map that bitch!)

I have had the pleasure of using AS3-Signals in combination with Robotlegs for quite a while now. It’s a great combo for communication within a Flex Application. I was at one point hesitant about using signals for communication within my components, until I started experimenting with them. You can check out the Community Examples page of the wiki to get up to speed on how use your basic Signal, DeluxeSignal and even NativeSignal. Also, check out some of the videos that John Lindquist has put together, as they are very informative.

I started out using NativeSignal inside my components, but I always felt that although it was a neat way of tying up my internals, it was missing a little something. That’s when I found NativeMappedSignal. The documentation in the source on this one was pretty good at giving me a rundown of what it did. You can basically map an event to more relevant data. This seemed to be the solution I was looking for and didn’t even know it.

To my surprise, my web searching revealed plenty of examples on using Signal, DeluxeSignal and NativeSignal, but I couldn’t find any solid examples of using NativeMappedSignal. I’m a visual person, so some examples or even video would have been great, but alas, I was left to just try it and learn. I’m glad I did.

First off, let’s start with a simple example of how you can use a NativeMappedSignal in a Flex component.

In this example, I have 2 Buttons and a TextInput. In this SkinnableComponent, where normally I would override the partAdded to add eventListeners, I am binding my NativeMappedSignals to each button and using the signal.mapTo() method to return strings that are unique to each signal. Then the same method is added as a listener to each signal. The method is not aware that an event happened, nor does it care where it came from. There’s no need to check the target to determine what text to display. This is a great convenience for me. Here is a sample of this little component in action.

You can also see that in the partRemoved() override, I just use the signal.removeAll() and set my signal to null when done. Easy peezy. That’s all there is to it. You can map the NativeMappedSignal to a string or more than one string or any object or objects as you’d like. It’s great.

Now, since I am a GIS developer using the ESRI Flex API, let me show you a simplified version of how I use NativeMappedSignals in my current application development.

In this sample component, I have a couple of buttons that activate a DrawTool. You can draw a square or line, depending on the button you click. So like the previous example, I bind each button to a NativeMappedSignal that maps to a string that represents the type of drawing action that I’d like to perform. I have a single method to activate my DrawTool. No need to create if/else or switch/case statements to check which button was clicked to determine that action.

Probably the more interesting part is the NativeMappedSignal that I bind to the DrawTool. When the DrawTool finishes drawing, it dispatches a DrawEvent.DRAW_END event, that carries the graphic that you just drew on the screen. The NativeMappedSignal is actually mapped to a function that returns this graphic, so again, the method I would normally use to handle the DrawEvent doesn’t care what event just occurred. You send it a graphic and it will add that graphic to the GraphicsLayer. Simplicity. Here is a sample of this component in action.

Of course these are very simple examples of how you can use NativeMappedSignal, but as you can probably already see, it can be a very powerful tool in transforming your events into useful, meaningful data. A use I have found is using them in BaseComponents, that I can extend. The extended components are sometimes not even aware that events are happening, I just add methods as listeners to inherited signals and voila, it’s like magic. Play with it a little bit for yourself, I don’t think you’ll be disappointed. Another benefit of signals, is that they are fast. Now, admittedly, I don’t know what performance results of NativeMappedSignal are, but even if they are marginally slower than normal Signals, the benefits are worth it in my opinion.

I hope you’ve found these little samples informative. Like I said, I had trouble finding specific examples using NativeMappedSignal and once I felt comfortable with them, I though I would share the little bit I have learned. Of course, I could be using them completely wrong or abusing them in some absurd fashion. If so, oh well, it fuckin’ works right?

But really, if I’m way off base, let me know, thanks!

By the way, there is a NativeRelaySignal that looks interesting, but again, I’m not sure how to use it or in what circumstances it would be useful, so if anyone has some insight on this one, I’d appreciate it.

O’Reilly Wish List (or, I like free books)

O’Reilly is running a contest to give away $500 of books. I don’t have $500 to spend on books, but I want books, so this is the best contest ever! If I win, I’ll take Print/E-books please, my Kindle needs some sweet sweet loving.

Learning PHP, MySQL, and JavaScript
This is a classic combination of technology for web development. I don’t know PHP, but I would love to put some time into learning it and how to use it with MySQL and JavaScript.

Head First Python
Everyone loves Python. I know enough Python to get stuff done with my geoprocessing services using ESRI ArcPy. Becoming more of a Python expert is one of my goals for the year.

Hadoop: The Definitive Guide
Cassandra: The Definitive Guide
The above two titles I chose because I am fascinated by the idea of working with large amounts of data and being able to mine that data. I don’t know if I’ll ever have the opportunity to use something Hadoop or Cassandra in my work environment, but I would be more than happy to see if I could use these tools for GIS somehow.

CouchDB: The Definitive Guide
MongoDB: The Definitive Guide
These two titles are something I’m currently excited about, as I know MongoDB has spatial query capabilities, and I already have some ideas about how I might be able to use it with Python in caching Geoprocessing results.

HTML5: Up and Running
I’m no HTML/CSS guru, but I’m about tools and if I can learn to use Canvas or other HTML5 tools to do some cool stuff, I’m all over it.

Programming Android
Developing Android Applications with Adobe AIR: Rough Cuts
Programming iOS 4
Mobile development is part of my goals for this year, and these titles would be a big help in that goal.

Algorithms in a Nutshell
I wasn’t a Computer Science student, so anything that can help me get a better grasp on algorithms, I would love to have.

So that’s my O’Reilly wish list. It’s a shot in the dark that I’ll win, but hey, you never know. Free books are the greatest books ever!

2011, Where do I go from here?

A little late to the party in terms of getting my resolutions written down, but better late than never. This past year, I have pretty much lived and breathed one Flex enterprise project at work. I am essentially the sole front-end developer/designer/architect/tester/victim of this application. I’ve learned a lot and I’m grateful for that, but I have also learned that I want to branch out to more than Flex/Actionscript as my specialty. I want to not only be a GIS developer, but I want to be a “Developer”. Of course, I have family goals of spending more quality time with wife and kids, having a happy family and a healthy year, but these are my developer growth goals. So here are my goals for 2011.

  1. Enhance my Javascript skills. I know enough Javascript to get some simple things done, but I really want to bring these skills up to par.
  2. Expand my Python skills. Python is a great language to learn for a lot of reasons. For one, it will enhance my skills working with ESRI geoprocessing tools, which is always a plus, but I also want to look at using Python to work with open source mapping solutions. Python seems to be the scripting language of choice in this regard.
  3. Learn Ruby. I have had chance to dabble with Ruby and I love it. This one ties into my next goal, but Ruby is a lot of fun and I think will help me expand on my developer skills as a whole.
  4. Branch out beyond GIS development. GIS development is what I do at work. But I want to expand my skills and start picking up some part-time freelance work that doesn’t need to be GIS focused. I’ll actually start pursuing work that involves building websites for folks. I’d like to maybe start with a couple of non-profit groups that I can work for free or cheap to build some experience. If someone needs some GIS-centric work done, I’ll gladly take it on.
  5. And to tie in to my previous goal, I want to improve my design skills. I’m practicing some PSD to HTML/CSS stuff, so that I can learn to build a site from scratch.
  6. Last but not least, if I have the time, I’m going to go mobile. Android/iPhone dev books are on my Kindle and I plan on using them.

Those are some pretty lofty goals, I know, but I’ve always been an eager learner. My situation is a little odd. I am not a developer by trade or education. I started doing development out of necessity as a GIS Analyst. I have had no apprenticeship or formal training, but I try to soak up as much as I can from where I can. GIS is my current focus, and I suppose it helps to have a niche, but who likes to be pigeonholed?

JSON features and ESRI Javascript API (noob adventures)

About a week ago, our test server that we have ArcGIS Server on decided to implode. Our IT department is in the process of building and installing all necessary software to get it back up and running. What that means to me is that most of my Flex work is stalled. Everything I do requires access to ArcGIS Server services and even WebOrb which we had loaded on the same machine.

So what does a Flex dev do when they can’t do Flex. He jumps feet first into a language he has limited experience in, JavaScript. Specifically, I took on the ESRI JavaScript API for a small project. Our need was that we are proposing putting a simple map on our external website for public use. Problem is, we do not want to open up our internal servers for this. There are policies and security concerns in place that are out of my hands, but the gist of it is we didn’t want to purchase a second ArcGIS Server license for such a small project.

Now, I knew that I could build a Flex application that could load a shapefile and display it on a map and all that jazz, but where’s the fun in doing something you already know how to do. Besides, I was thinking of future proofing this little thing for mobile use.

So I did some research and there was so far no way to load a shapefile into JavaScript and display it on the map. But, after reading through the API docs, I found that I could load JSON features into the map. I was a little concerned because when I have attempted to load complex polygons as JSON into Flex, performance wasn’t very good. So imagine my surprise when performance was spot on in JavaScript. This practice may be old hat, as a lot of JSON is used in the ESRI JavaScript API, but I had not seen an example to explicitly load features in this manner.

You can see an example of a map loading JSON features of States here.

Now, I am not JavaScript ninja, so please excuse any “bad form” in my code. I’m still learning.

The key was, when you get your JSON results,  you want to iterate through the results["features"] to find attributes and geometries. Here is the script for loading JSON features. Once you get that far, the rest is easy. Create the graphics, load attributes into an InfoTemplate if you’d like and voila, you have a nice map with features loaded without the need for your own ArcGIS Server to serve the data out.

It may not seem like a big deal, but I didn’t find any quick guides on this info, so I just thought I would share what I learned this past week.

My test server should be back up soon, so I’ll be back to Flex’n, but I think I’ll be doing some more digging into JavaScript for some simpler applications. One drawback for me is that I love IDE tools, like FDT and IntelliJ, but I’ve been having a hard time finding an IDE that works well with JavaScript, custom objects, libraries like Dojo and jQuery but I’ll keep looking. I’m not a convert, but it is a bit of fun.