Many of the desktop GIS paradigms have unfortunately made their way to the web. Second only to the ‘Identify’ tool in popularity, the checkbox for toggling layers is still the most common way to turn map layers on and off. While I appreciate the simplicity it just doesn’t seem all that, well, elegant. And now that skeuomorphism is out and flat design is here to stay, the good ole checkbox might just be going the way of
This doesn’t hurt my feelings but it does leave some interesting voids and presents lots of possibilities.
Here’s my first departure from the old paradigm that I’m using pretty regularly. A sized
< div > floating directly over the map with some roundy edges and applying slight transparency. Position these togglable layer elements in a corner or off to the side and they work pretty well.
dual purpose layer toggler and legend
Set the css hover to
cursor: pointer and change the background color and it becomes obvious that you can interact with it. Adding an icon can be used to invite users and indicate what it does. This allows you to maximize space by using the element for both togglability and as a legend. Moving the element into the background by lightening the background color, removing the border and changing the icon indicates its in-visibility. Conversely, applying a solid border, increasing opacity and swapping icons give the visual cue that this thing is live.
Wire up a click event for each togglable-layer element to toggle the visibility of the layer on the map and also to toggle css classes that visually indicate the visibility state of that layer.
You can see this in action,
demo of togglable layers using recreation sites at Wenatchee National Forest
Source of demo on github.
I realize that there is a growing contingency of ‘no GIS’ proponents who would do away with the concept of turning layers of data on and off and, in some contexts, I agree. But there are many use cases where this can be extremely powerful and, if done well, dare I say, elegant.
So I put together a dead simple interface to convert geojson to arcjson using the esri geojson utils repo on github. I also threw in a feature to view it on a map, but its spotty…
It truly is a wrapper around geojson utils.
Include, create, use
I ended up doing this for a few reasons: I wanted to try out the awesome geoJson creation and editing tool by @tmcw, geojson.io. And I also wanted to play with the new Boostrap 3 flatness, a significant departure from the old version in both workings and looks.
The new developers.arcgis.com allowed me to quickly create and publish a new feature service to contain the new data. I just copied the output from geojson.io, pasted it into a text box, hit the button and I had arcJson. Another copy and paste to get it into the feature service rest endpoint, addFeatures and I had my regions in my map service.
A note that if you need the same workflow you need to ‘unwrap’ the output arcjson into just the array of features i.e. remove the outter ‘features’ object before pasting into an addFeatures end point. Peel off this bit here and the very last curly too:
Definitely ‘innovation time’ as this is just a bridge across the open water until esri provides full support for geojson. Let me know if you find it useful.
For many of my clients purchasing and managing ArcGIS Server has been out of the question based on limited IT and GIS resources. So for years I’ve been testing hosted services that would allow them to get maps out to their customers via the web. None of them allowed for timely data updates to ever changing data however. So naturally when ArcGIS Online rolled out I had to take it for a spin to see how it might work.
My goal is to publish a map service to ArcGIS Online once and be able to update it through a simple console application that could be launched at some interval (hourly, daily, weekly).
Here’s what I did:
Publish the feature service via ArcGIS Desktop 10.1
Once you have an ArcGIS Online account and ArcGIS Desktop 10.1 installed it’s easy peasy to publish a feature service. (how to)
In order to mimic a real world scenario as best I could (for a geo dev anyway) I created a fairly simple web map that shows recreation sites on top of a topo base map. Clicking on the map then displays that general area in a floating box with an aerial base and info about a rec site as the title if one is within clicked range. Simple (yet I have spent far too much time just browsing it). I’ll be honest, that was the fun part. The feature service is obviously also available directly in an ArcGIS Online map.
Develop the .Net console application to update the feature service data from a local source
My console app is using the ArcObjects .Net SDK to access a feature class within a file geodatabase to mimic my clients’ typical GIS infrastructure. This requires an ArcGIS license of any flavor to be available from the running server. This could just as easily be any format you like however since all we’re really doing is building JSON objects to pass directly to the ArcGIS Spatial Data Server REST API.
I used brute force in deleting all features and then adding them all back but I could imagine something a bit more elegant. I also noticed in Fiddler that ArcGIS Online uses the applyEdits method for any edit operation (delete, add, update). applyEdits also allows you to cancel the entire request if anything fails. But I’m going for simplicity here.
Here’s the C# code that works to make these updates:
You can also find the source project on github
There’s lots of room for improvement here such as serializing the json and handling the updates more elegantly but this is a working example of how you might keep a hosted map service on ArcGIS Online updated.
I’m guessing there are use cases I hadn’t thought of and would love to hear them.