After years of randomly forgetting whether the carret (^) and dollar sign ($) represent the beginning or end of a regular expression match, I came up with this rhyme this morning.

Start with the carrot, end with the money.

Stupid, but it helps.

Posted in geeky | No Comments »

Some nanomaps Updates December 13th, 2010

I spent some time getting api docs and some other odds and ends done for Nanomaps.  The front page on github (see README) has an example of the “declarative mapping” mode that this library enables.  Basically, you can choose to just add your map content directly to your HTML and then make a simple JavaScript call to turn the container into a map.

Here’s an example of declaratively constructing a map, using CSS to style the markers and copyright.

<style>
    #map {
        width: 640px;
        height: 480px;
    }

    #mapcopy {
        z-index: 50;
        position: absolute;
        right: 2px; bottom: 2px;
        text-align: right;
        font-family: sans-serif;
        font-size: 10px;
        -webkit-user-select:none;
        -moz-user-select:none;
        cursor: default;
    }
    #mapcopy a:visited {
        color: #00f;
    }

    .poi {
        z-index: 100;
        margin-left: -10px;
        margin-top: -32px;
        display: none;  /* make not displayed by default to avoid startup flicker */
    }
</style>

<div id="mymap">
    <img src="images/red-pushpin.png" latitude="39.780533" longitude="-104.988896" />

    <span>Tiles Courtesy of <a href="http://open.mapquest.co.uk/" target="_blank">MapQuest</a> <img width="16" height="16" src="http://developer.mapquest.com/content/osm/mq_logo.png" border="0"></span>
    <br />
    <span>&copy; <a href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a></span>
</div>

<script>
    var map=new nanomaps.MapSurface(document.getElementById("mymap"));
    map.attach(new nanomaps.TileLayer({
       tileSrc: "http://otile${modulo:1,2,3}.mqcdn.com/tiles/1.0.0/osm/${level}/${tileX}/${tileY}.png" }));
</script>

Funny – Cygwin not requried December 8th, 2010

I ran across this wiki help page on installing Node.js under Cygwin.  It notes at the top that you don’t need to have a working cygwin installation, but step 1 is “Grab and Install Cygwin.”  I’m sure many had a momentary flash of hope only to be dashed by the bitter truth one line later.

Posted in geeky | No Comments »

Working Version of Nanomaps December 7th, 2010

In my previous post, I discussed a little project I started to create a super-small, no frills JavaScript map display library.  Well, it’s mostly working, with still a lot of things to do.  Specifically, here’s what it’s got:

  • Standard desktop gestures for panning and zooming a map (double click, scroll wheel, drag)
  • Standard touch gestures for panning and zooming (only tried on IOS 4.1 so far)
  • Talks to OSM tile servers by default (setup for MapQuest OSM tiles now)
  • Basic zooming to arbitrary resolution.  This still flickers and I know how to really get it right but I wanted to get the event bits in place before experimenting with the core rendering further

What it doesn’t have:

  • IE support.  I’ll add some of this in a separate module.
  • Any testing except on Firefox 3.6/Mac, Safari 5.0.2/Mac and iOS 4.1.
  • Any of the stuff you will find in a full-featured map display library.  This one is structured, however, to let you integrate it easily with your own DOM manipulation and I plan to add a canned jQuery plugin at some point.

The download size of the scripts is 5.1KB (post-GZIP).

So, still a work in progress, but there is a bit more working today than there was.

GitHub: https://github.com/stellaeof/nanomaps

Demo: http://www.laurenzo.org/~stella/nanomaps/demo.html

I’ve got my own reasons for wanting something like this, but drop me a line or watch the GitHub repo if you’re interested in seeing this evolve as well.

Posted in geeky, nanomaps | 1 Comment »

It sure feels that way.  Amazingly, a standard OpenLayers build weighs in excess of 900KB of minified JavaScript.  Granted, GZIP helps a bit, but that is a ton of stuff to ask a poor browser to interpret if you’re goal is just to display a basic map.  After a bit of poking, I found you can build a “lite” version that is only a few hundred KB and strips out most of the features.  And this is when I stopped looking.  Aside from a bloated codebase, it doesn’t really support mobile phones easily (as in limited touch support and extremely bad performance) which is kindof what I was looking to display a map on.

As I was assessing the landscape, I got this incredible sense of deja-vu.  You see, up until recently, I worked for MapQuest.  While there, I wrote a few mapping toolkits or rendering libraries and know a bit about what it takes to build one well.  The MapQuest JavaScript API, while not perfect and suffering from a host of legacy issues such as crazy projection and zoom levels, layers of backwards compatibility support and licensing restrictions, is actually a pretty compact and performant bit of JavaScript.  I rewrote it a couple of years ago when we launched our first mobile Safari website and was basically focused on limiting code size and maximizing performance.  At the time the entire mapping API was about the size of a tile to download.  It’s grown a bit since then but this is mainly through the addition of layer upon layer of legacy support and a number of bits needed to run MapQuest.com on the desktop.

With this experience in mind, I was upset to find that despite massive innovation over the past few years on the server side of open source geo, basically everyone is still focused on OpenLayers on the client side.  And OpenLayers is in desperate need of a reboot – which the dev team is doing as part of a 3.0 rebuild.  This is a great thing for anyone needing a full map-centric JavaScript map library, but it still leaves a niche for a super-lightweight, DOM-centric map library to fill in on the low end.

So you know where this is going… I started writing yet another JavaScript mapping library.  I want it to be small and fast for doing simple things (which in my experience comprises 90% of the use cases).  I’d also like it to work very closely with the DOM.  This isn’t 2005 when we were all trying to build crazy abstractions on top of the DOM to hide it.  I want to be able to have the library do enough to manage the coordinate system, tiles, etc and then just let me start attaching DOM content instead of working through layers of leaky abstractions.

It’s not all there in the head yet, but what I’ve got now will render standard web mercator tiles at arbitrary resolution, supports smoothly zooming between native resolutions of the tile server and supports attaching arbitrary DOM elements to the map by either adding a “positioning delegate” object (which is what complex elements like a Tile Layer use to draw themselves) or falling back to the default delegate which just assumes that the element has a geo property which contains a Lat/Lng and pixel offset and will take care of managing things from there.

So, very not done yet, but it weighs in at 7KB raw and 3KB gzipped.  I expect that to perhaps double by the time I get non-brain-damaged background tile invalidation and event handling in place.  I don’t really plan to add more than those basics.  The rest can be managed through normal DOM manipulations, of which there are a plethora of tools and approaches.

Here’s the GitHub repo: https://github.com/stellaeof/nanomaps

Posted in geeky, nanomaps | 1 Comment »

The death star vs the x-wing November 27th, 2010

I got a big chuckle out of this presentation.

Posted in geeky | No Comments »

jEdit Hacks November 23rd, 2010

jEdit is one of my favorite text editors but some of its oddities have driven me crazy for years. I finally had a few minutes and decided to fix them.

At the top of the list is the stupid way it handles re-indention on certain keystrokes. This really effects JavaScript because it will always re-indent the current line on the press of “{” or “[“. This is bad because of the way that functions are typically implemented.

There is no way in the mode file to override this behavior, so I patched the source to allow a different mode property that makes the behavior more explicit.

I packaged it all up in a little git repo with a script to checkout, patch, build and install updates: https://github.com/stellaeof/jedithacks

Tags: ,
Posted in geeky | No Comments »

node.js November 21st, 2010

My last day at MapQuest is fast approaching (December 1st), and while I have plenty to do in order to wrap things up, I’m feeling relief because the long list of todos that has always extended to the indefinite horizon is now a finite list.

The great part is that I’ve had some extra cycles to catch up on tech topics that I’ve missed over the last four years or so!  Today I started looking at NodeJS, which as near as I can tell, is just about the coolest thing ever.  Traditional asynchronous IO, while arguably the “right” way to perform most tasks, is just so freaking hard to do right in so many environments.  One blocking operation, and kaaa-boom, your entire system blows up.

NodeJS seems to solve this pretty well, and you program it in super-fast V8 JavaScript to boot.  I’m looking at it for this JSON-Switch concept I’ve been kicking around in the back of my head for a while.  Basically, its an extendable server for switching JSON or JSON-friendly datasources.  Coding such a thing in JavaScript satisfies my sense of feng shui and should be pretty fast to boot.

Tags:
Posted in geeky | No Comments »