<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>GeoJason</title>
  <link href="http://JasonSanford.github.com/atom.xml" rel="self"/>
  <link href="http://JasonSanford.github.com/"/>
  <updated>2013-05-31T16:45:52-06:00</updated>
  <id>http://JasonSanford.github.com/</id>
  <author>
    <name>Jason Sanford</name>
    
  </author>

  
  <entry>
    <title>Leaflet Vector Layers</title>
    <link href="http://JasonSanford.github.com/2012/leaflet-vector-layers/"/>
    <updated>2012-01-24T15:23:00-07:00</updated>
    <id>http://JasonSanford.github.com/2012/leaflet-vector-layers</id>
    <content type="html">&lt;p&gt;A few weeks back I &lt;a href=&quot;http://JasonSanford.github.com/2011/google-vector-layers/&quot;&gt;posted about Google Vector Layers&lt;/a&gt; which helps you create interactive layers with the Google Maps API and data from common providers like &lt;a href=&quot;http://www.esri.com/software/arcgis/arcgisserver/index.html&quot;&gt;ArcGIS Server&lt;/a&gt;, &lt;a href=&quot;http://www.arc2earth.com/&quot;&gt;Arc2Earth&lt;/a&gt;, &lt;a href=&quot;https://cartodb.com/&quot;&gt;CartoDB&lt;/a&gt; and &lt;a href=&quot;http://geocommons.com/&quot;&gt;GeoCommons&lt;/a&gt;. I&amp;#8217;m a big fan of the Google Maps API but lately there have been &lt;a href=&quot;https://plus.google.com/u/0/118383351194421484817/posts/foj5A1fURGt&quot;&gt;lots&lt;/a&gt; of &lt;a href=&quot;http://blog.nestoria.co.uk/why-and-how-weve-switched-away-from-google-ma&quot;&gt;folks&lt;/a&gt; swtiching to web mapping alternatives, like &lt;a href=&quot;http://leaflet.cloudmade.com/&quot;&gt;Leaflet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, I made &lt;a href=&quot;http://JasonSanford.github.com/leaflet-vector-layers&quot;&gt;Leaflet Vector Layers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://JasonSanford.github.com/images/posts/full/leaflet-vector-layers.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;Leaflet Vector Layers is Google Vector Layers&amp;#8217; twin brother. The API is nearly identical (&lt;code&gt;new gvector.AGS({&#8230;})&lt;/code&gt; vs. &lt;code&gt;new lvector.AGS({&#8230;})&lt;/code&gt;) and the library works exactly the same &amp;#8211; fetching features as the user pans and zooms the map, or fetching all features at once for smaller data sets.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s also great for use behind the firewall where the &lt;a href=&quot;http://code.google.com/apis/maps/terms.html&quot;&gt;Google Maps terms&lt;/a&gt; or &lt;a href=&quot;http://code.google.com/apis/maps/faq.html#usage_pricing&quot;&gt;pricing&lt;/a&gt; can be prohibitive for some organizations.&lt;/p&gt;

&lt;p&gt;Leaflet Vector Layers has all of the features of the Google Maps flavor like multi-provider support, popup (InfoWindow) templating, simple symbology definitions, support for dynamic data and scale dependent rendering.&lt;/p&gt;

&lt;p&gt;So, check out the links below for an overview of the library, documentation and demos.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;Links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/leaflet-vector-layers/&quot;&gt;The Main Page&lt;/a&gt; (Start Here) - This will link you to the source code, demos and documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/JasonSanford/leaflet-vector-layers&quot;&gt;The GitHub Repo&lt;/a&gt; - Please send issues, feature requests and code contributions here&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/leaflet-vector-layers/documentation/&quot;&gt;Documentation&lt;/a&gt; - Go here when you get console errors&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/leaflet-vector-layers/demos/&quot;&gt;Demos&lt;/a&gt; - Some good code to get you started&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  
  <entry>
    <title>Google Vector Layers</title>
    <link href="http://JasonSanford.github.com/2011/google-vector-layers/"/>
    <updated>2011-12-20T09:02:00-07:00</updated>
    <id>http://JasonSanford.github.com/2011/google-vector-layers</id>
    <content type="html">&lt;script src=&quot;http://JasonSanford.github.com/javascripts/libs/jquery-1.6.4.min.js&quot;&gt;&lt;/script&gt;


&lt;script src=&quot;http://JasonSanford.github.com/google-vector-layers/dist/gvector.js&quot;&gt;&lt;/script&gt;


&lt;script&gt;jQuery.noConflict();&lt;/script&gt;


&lt;script type=&quot;text/javascript&quot;&gt;
var map1, map2, map3;

var ags_light_rail_lines;
var ags_light_rail_lines_loaded = false;

var cartodb_flood_zones;
var cartodb_flood_zones_loaded = false
    
jQuery(document).ready(function() {

    map1 = new google.maps.Map(document.getElementById(&quot;map-container-1&quot;), {
        center: new google.maps.LatLng(39.74154151936245, -104.99968229904174),
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        noClear: true
    });
    
    ags_light_rail = new gvector.AGS({
        url: &quot;http://maps.rtd-denver.com/ArcGIS/rest/services/SystemMapLiteGoogleVectors/MapServer/1&quot;,
        fields: &quot;*&quot;,
        scaleRange: [13, 20],
        showAll: true,
        symbology: {
            type: &quot;single&quot;,
            vectorOptions: {
                strokeWeight: 4,
                strokeOpacity: 0.8,
                strokeColor: &quot;#004a00&quot;
            }    
        },
        infoWindowTemplate: &#8216;&lt;div class=&quot;iw-content&quot;&gt;&lt;h3&gt;Light Rail Line&lt;/h3&gt;&lt;table class=&quot;condensed-table&quot;&gt;&lt;tr&gt;&lt;th&gt;Route: &lt;/th&gt;&lt;td&gt;{ROUTE}&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&#8217;
    });

    google.maps.event.addListener(map1, &quot;tilesloaded&quot;, function() {
        if (!ags_light_rail_lines_loaded) {
            ags_light_rail.setMap(map1);
            ags_light_rail_lines_loaded = true;
        }
    });
    
    map2 = new google.maps.Map(document.getElementById(&quot;map-container-2&quot;), {
        center: new google.maps.LatLng(35.02218076922061, -80.67909174217226),
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.SATELLITE,
        noClear: true
    });
    
    cartodb_flood_zones = new gvector.CartoDB({
        user: &quot;geojason&quot;,
        table: &quot;flood_zones&quot;,
        fields: &quot;cartodb_id,label,st_simplify(the_geom,0.000008) the_geom&quot;,
        scaleRange: [14, 20],
        symbology: {
            type: &quot;unique&quot;,
            property: &quot;label&quot;,
            values: [
                {
                    value: &quot;AE&quot;,
                    vectorOptions: {
                        fillColor: &quot;#2f952f&quot;,
                        fillOpacity: 0.6,
                        strokeWeight: 1,
                        strokeColor: &quot;#fff&quot;,
                        strokeOpacity: 0
                    }
                },
                {
                    value: &quot;AE-FW&quot;,
                    vectorOptions: {
                        fillColor: &quot;#004a00&quot;,
                        fillOpacity: 0.6,
                        strokeWeight: 1,
                        strokeColor: &quot;#fff&quot;,
                        strokeOpacity: 0
                    }
                },
                {
                    value: &quot;0.2% Annual Chance&quot;,
                    vectorOptions: {
                        fillColor: &quot;#aaff7a&quot;,
                        fillOpacity: 0.6,
                        strokeWeight: 1,
                        strokeColor: &quot;#fff&quot;,
                        strokeOpacity: 0
                    }
                }
            ],
        },
        infoWindowTemplate: &#8216;&lt;div class=&quot;iw-content&quot;&gt;&lt;h3&gt;Flood Zone&lt;/h3&gt;&lt;table class=&quot;condensed-table&quot;&gt;&lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;&lt;td&gt;{label}&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&#8217;,
        singleInfoWindow: true
    });
    
    google.maps.event.addListener(map2, &quot;tilesloaded&quot;, function() {
        if (!cartodb_flood_zones_loaded) {
            cartodb_flood_zones.setMap(map2);
            cartodb_flood_zones_loaded = true;
        }
    });
    
});
&lt;/script&gt;


&lt;p&gt;There&amp;#8217;s no shortage of geo data providers these days. It&amp;#8217;s quite easy to publish data and make it available to the world in minutes using software like &lt;a href=&quot;http://www.esri.com/software/arcgis/arcgisserver/index.html&quot;&gt;ArcGIS Server&lt;/a&gt;, &lt;a href=&quot;http://geocommons.com/&quot;&gt;Geocommons&lt;/a&gt;, &lt;a href=&quot;http://www.arc2earth.com/&quot;&gt;Arc2Earth&lt;/a&gt; and &lt;a href=&quot;https://cartodb.com/&quot;&gt;CartoDB&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What&amp;#8217;s sometimes not easy as it could be, is taking data from these providers and showing them on your slippy map of choice, Google Maps.&lt;/p&gt;

&lt;p&gt;For the past few months in my downtime I&amp;#8217;ve been working on a library that makes it much easier to view and interact with your data in these services &amp;#8211; &lt;a href=&quot;http://geojason.info/google-vector-layers/&quot;&gt;Google Vector Layers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With just a few lines of code you can view data from a number of geo web services, symbolize it based on property values and create highly customized InfoWindows using the feature data.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/google-vector-layers.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;The library works by listening to map events (pan and zoom) and then fetching features within the map&amp;#8217;s extent after each event. This method works great for data sets with lots of features that you want to interact with, but not load all at once. But you can also load all data initially if you&amp;#8217;ve only got a handful of features and prefer a less chatty approach.&lt;/p&gt;

&lt;h2&gt;Features&lt;/h2&gt;

&lt;p&gt;There are number of things that make this library quite handy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multi-Provider Support&lt;/strong&gt; - Current support for ArcGIS Server, Arc2Earth, Geocommons and CartoDB (&lt;a href=&quot;https://github.com/JasonSanford/google-vector-layers/issues/16&quot;&gt;with more in mind&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Easy InfoWindow Templating&lt;/strong&gt; - Create InfoWindow templates with a simple string with property names &lt;code&gt;{mustached}&lt;/code&gt; or with a function that gets passed feature properties, and should return valid HTML for the InfoWindow&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic Data Support&lt;/strong&gt; - Easily visualize &lt;a href=&quot;http://geojason.info/google-vector-layers/demos/arcgis-server/#live-autoupdate&quot;&gt;live data&lt;/a&gt; that auto-updates at an interval that you set (and makes sense for your data&amp;#8217;s update frequency)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simple, Powerful Symbology&lt;/strong&gt; - Style your layers with a single symbology, a unique symbol for specific attribute values or set symbols to display if a feature&amp;#8217;s attibutes are within a specific range. Or &amp;#8230;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use Your Current Styles&lt;/strong&gt; - If you&amp;#8217;re using an ArcGIS Server layer you can use the styles you&amp;#8217;ve already spent time creating in ArcMap&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scale Dependent Rendering&lt;/strong&gt; - You wouldn&amp;#8217;t want to show lots of features with complex geometries at lower zoom levels - Using &lt;code&gt;scaleRange&lt;/code&gt; lets you set the minimum and maximum scales a layer should be visible&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The &lt;a href=&quot;http://geojason.info/google-vector-layers/&quot;&gt;documentation and demo pages&lt;/a&gt; have much more detail about all of these features but it&amp;#8217;s worth showing a few examples to see how things work.&lt;/p&gt;

&lt;h2&gt;Examples&lt;/h2&gt;

&lt;h3&gt;Light Rail Lines&lt;/h3&gt;

&lt;p&gt;This very simple example shows RTD&amp;#8217;s Light Rail Lines as a simple green line. There&amp;#8217;s also a string based &lt;code&gt;infoWindowTemplate&lt;/code&gt; so clicking features gets you more info. Also, we&amp;#8217;re using the &lt;code&gt;showAll&lt;/code&gt; option because there are only a hanful of features so there&amp;#8217;s no sense re-fetching features with each map pan or zoom.&lt;/p&gt;

&lt;div class=&quot;google-maps&quot; id=&quot;map-container-1&quot; style=&quot;height: 400px; position: relative; border: 1px solid #CCC; margin-bottom: 20px;&quot;&gt;&lt;/div&gt;




&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;12&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;13&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;14&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;15&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;ags_light_rail&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gvector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;AGS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;http://maps.rtd-denver.com/ArcGIS/rest/services/SystemMapLiteGoogleVectors/MapServer/1&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;scaleRange&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;showAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;symbology&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;single&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;vectorOptions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;nx&quot;&gt;strokeWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;nx&quot;&gt;strokeOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;nx&quot;&gt;strokeColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#004a00&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;infoWindowTemplate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;div class=&amp;quot;iw-content&amp;quot;&amp;gt;&amp;lt;h3&amp;gt;Light Rail Line&amp;lt;/h3&amp;gt;&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Route: &amp;lt;/th&amp;gt;&amp;lt;td&amp;gt;{ROUTE}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;lt;/div&amp;gt;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;hr /&gt;

&lt;h3&gt;Flood Zones&lt;/h3&gt;

&lt;p&gt;This example pulls data from CartoDB. Here we&amp;#8217;re using a unique &lt;code&gt;symbology&lt;/code&gt; type to show different Flood Zone Types. You&amp;#8217;ll also see that we pass a &lt;code&gt;ST_Simplify&lt;/code&gt; function to the PostGIS powered back end at CartoDB.&lt;/p&gt;

&lt;div class=&quot;google-maps&quot; id=&quot;map-container-2&quot; style=&quot;height: 400px; position: relative; border: 1px solid #CCC; margin-bottom: 20px;&quot;&gt;&lt;/div&gt;




&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;12&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;13&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;14&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;15&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;16&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;17&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;18&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;19&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;20&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;21&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;22&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;23&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;24&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;25&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;26&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;27&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;28&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;29&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;30&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;31&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;32&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;33&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;34&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;35&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;36&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;37&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;38&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;39&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;40&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;41&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;42&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;43&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;44&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;cartodb_flood_zones&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gvector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CartoDB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;geojason&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;flood_zones&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;cartodb_id,label,st_simplify(the_geom,0.000008) the_geom&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;scaleRange&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;symbology&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;unique&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;label&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;AE&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;vectorOptions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#2f952f&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;AE-FW&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;vectorOptions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#004a00&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;0.2% Annual Chance&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;nx&quot;&gt;vectorOptions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#aaff7a&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;fillOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                    &lt;span class=&quot;nx&quot;&gt;strokeOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;infoWindowTemplate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;div class=&amp;quot;iw-content&amp;quot;&amp;gt;&amp;lt;h3&amp;gt;Flood Zone&amp;lt;/h3&amp;gt;&amp;lt;table class=&amp;quot;condensed-table&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&amp;lt;td&amp;gt;{label}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;lt;/div&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;singleInfoWindow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;hr /&gt;

&lt;h2&gt;Links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/google-vector-layers/&quot;&gt;The Main Page&lt;/a&gt; (Start Here) - This will link you to the source code, demos and documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/JasonSanford/google-vector-layers&quot;&gt;The GitHub Repo&lt;/a&gt; - Please send issues, feature requests and code contributions here&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/google-vector-layers/documentation/&quot;&gt;Documentation&lt;/a&gt; - Go here when you get console errors&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://geojason.info/google-vector-layers/demos/&quot;&gt;Demos&lt;/a&gt; - Some good code to get you started&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  
  <entry>
    <title>The Open Streets Style for TileMill</title>
    <link href="http://JasonSanford.github.com/2011/the-open-streets-style-for-tilemill/"/>
    <updated>2011-10-08T09:02:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/the-open-streets-style-for-tilemill</id>
    <content type="html">&lt;p&gt;If you need a base map or two for your web mapping application, you&amp;#8217;ve got quite a few options to choose from these days.&lt;/p&gt;

&lt;p&gt;You can use the &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/reference.html&quot;&gt;Google Maps API&lt;/a&gt; which provides street, aerial and a hybrid flavors. Unfortunately the &lt;a href=&quot;http://code.google.com/apis/maps/terms.html&quot;&gt;terms&lt;/a&gt; prevent the use of map tiles outside of Google Maps API.&lt;/p&gt;

&lt;p&gt;MapQuest, as part of their &lt;a href=&quot;http://developer.mapquest.com/web/products/open&quot;&gt;Open MapQuest efforts&lt;/a&gt;, offers an OSM-based street map as well as an aerial map available for free, provided you &lt;a href=&quot;http://developer.mapquest.com/web/products/open/map#terms&quot;&gt;credit&lt;/a&gt; MapQuest and OSM contributors where necessary.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://cloudmade.com/&quot;&gt;Cloudmade&lt;/a&gt; serves highly customizable base map tiles also based on OpenStreetMap data.&lt;/p&gt;

&lt;p&gt;But what if you need a base map for offline use or behind the firewall? You can spend a lot of time creating a tweaking a style to make it look as good as some of the commercial providers, or you can check out the &lt;a href=&quot;https://github.com/mapbox/open-streets-style&quot;&gt;Open Streets Style&lt;/a&gt; for &lt;a href=&quot;http://mapbox.com/tilemill/&quot;&gt;TileMill&lt;/a&gt;. This style is designed to work with a PostGIS database populated with OpenStreetMap data via the &lt;code&gt;osm2pgsql&lt;/code&gt; command. There are just a few steps you need to follow to get up and running:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download &lt;a href=&quot;http://wiki.openstreetmap.org/wiki/Planet.osm&quot;&gt;planet.osm&lt;/a&gt; in whole or in an aggregate form. I often use the &lt;a href=&quot;http://download.geofabrik.de/osm/&quot;&gt;OSM downloads from geofabrik&lt;/a&gt; which, in the US, provide OSM data down to the state level.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the &lt;code&gt;osm2pgsql&lt;/code&gt; command to populate your PostGIS database with OpenStreetMap data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class=&#8217;code&#8217;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8221;&gt;&lt;span class=&#8217;line&#8217;&gt;osm2pgsql -U user_name -P 5432 -d db_name planet.osm&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download the &lt;a href=&quot;https://github.com/mapbox/open-streets-style&quot;&gt;open streets style&lt;/a&gt; from MapBox&amp;#8217; GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Edit the configuration script (configure.py) with your database connection settings.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class=&#8217;code&#8217;&gt;&lt;figcaption&gt;&lt;span&gt;config.py  &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;python&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env python&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;c&quot;&gt;## OPEN STREETS CONFIGURATION OPTIONS ##&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;c&quot;&gt;# PostGIS connection setup&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;n&quot;&gt;host&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;localhost&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;5432&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;n&quot;&gt;dbname&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;geo&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;postgres&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Pa$$w0rD&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;Run the configuration python script.&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class=&#8217;code&#8217;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8221;&gt;&lt;span class=&#8217;line&#8217;&gt;./configure.py&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;The style definitions in the &lt;code&gt;open-streets&lt;/code&gt; subdirectory have been changed to point to the database declared above. Copy this directory to your TileMill projects directory (&lt;code&gt;/Users/JohnDoe/Documents/MapBox/project&lt;/code&gt; on a Mac) and start TileMill.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The first time you open the open-streets project it will take a while for the map to appear as hundreds of MBs of shapefiles are being downloaded. These include water body and administrative boundaries. You can store these locally to work around this.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve created a &lt;a href=&quot;http://JasonSanford.github.com/demos/open-streets-style&quot;&gt;demo page&lt;/a&gt; showing what the style looks like working with OSM data from the Denver, Colorado area. Click the image below to see the style for yourself.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/demos/open-streets-style&quot;&gt;&lt;img class=&quot;center&quot; src=&quot;http://JasonSanford.github.com/images/posts/full/open-streets-style.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>The 2011 FOSS4G Map - Mobile Edition</title>
    <link href="http://JasonSanford.github.com/2011/the-2011-foss4g-map-mobile-edition/"/>
    <updated>2011-09-10T15:30:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/the-2011-foss4g-map-mobile-edition</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/foss4g-map-mobile.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/foss4g-map-mobile.png&quot; title=&quot;FOSS4G Map Mobile&quot; &gt;&lt;/a&gt;I&amp;#8217;ve updated the  &lt;a href=&quot;http://2011.foss4g.org/content/foss4g-map&quot;&gt;2011 FOSS4G map&lt;/a&gt; mentioned in my previous post to be a little more mobile friendly. You can even use some HTML5 geolocation to find where you&amp;#8217;re at.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s a link to this map on FOSS4G&amp;#8217;s interactive map page or the direct link is http://foss4g.geojason.info*.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m fairly new to mobile web development so give me a shout if you find some bugs.&lt;/p&gt;

&lt;p&gt;* Sorry, no longer available. I&amp;#8217;m tired of paying my AWS bill.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>The 2011 FOSS4G Map</title>
    <link href="http://JasonSanford.github.com/2011/the-2011-foss4g-map/"/>
    <updated>2011-09-07T15:04:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/the-2011-foss4g-map</id>
    <content type="html">&lt;p&gt;If you&amp;#8217;re like me, at any given time you&amp;#8217;ve got a number of new software products you&amp;#8217;ve been hearing about, but just haven&amp;#8217;t had time to tinker with. A few weeks back &lt;a href=&quot;http://geothought.blogspot.com&quot;&gt;Peter Batty&lt;/a&gt; asked if I&amp;#8217;d be interested in creating an interactive map for the upcoming FOSS4G conference that will be here in Denver. This sounded like the perfect opportunity to try out some new open source geo tools.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/foss4g-map-initial-screen.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/foss4g-map-initial-screen.png&quot;&gt;&lt;/a&gt;I&amp;#8217;ll start with a &lt;a href=&quot;http://2011.foss4g.org/content/foss4g-map&quot;&gt;link to the map&lt;/a&gt; (http://2011.foss4g.org/content/foss4g-map) and tell you a little about how it works and what was used to create it. Visiting the site above displays a slippy map that you can pan and zoom like any other. The initial map shows four FOSS4G Venues as well as some light rail lines and stops to help you get around. As you zoom into the map you&amp;#8217;ll see more information about bars, cafes, restaurants and even &lt;a href=&quot;http://denver.bcycle.com/&quot;&gt;bicycle rental stations&lt;/a&gt;. Clicking these icons will show varying amounts of information in either a popup window or a small panel in the bottom left corner of the map.&lt;/p&gt;

&lt;h2&gt;All the pieces&lt;/h2&gt;

&lt;p&gt;The mapping library I&amp;#8217;m using is &lt;a href=&quot;http://leaflet.cloudmade.com&quot;&gt;Leaflet&lt;/a&gt;, from &lt;a href=&quot;http://www.cloudmade.com&quot; title=&quot;&quot;&gt;CloudMade&lt;/a&gt;. This is a great library that is very lightweight, easy to use, works great on mobile and most importantly, is open source. The &lt;a href=&quot;https://github.com/mourner&quot;&gt;core developer&lt;/a&gt; is very responsive to &lt;a href=&quot;https://github.com/CloudMade/Leaflet/issues&quot;&gt;bugs and feature requests&lt;/a&gt; which is encouraging for those just getting started with Leaflet. If you haven&amp;#8217;t checked out Leaflet yet or haven&amp;#8217;t in the last few months, do yourself a favor and take a look. It&amp;#8217;s grown by leaps and bounds lately and bugs are squashed often.&lt;/p&gt;

&lt;p&gt;As I mentioned before the map shows various local amenities in the downtown Denver area. These come from &lt;a href=&quot;http://openstreetmap.org&quot;&gt;OpenStreetMap&lt;/a&gt; and are periodically updated to keep the map fresh with updates from you. I&amp;#8217;m sure you&amp;#8217;ve all heard about OpenStreetMap. It&amp;#8217;s awesome. End of story.&lt;/p&gt;

&lt;p&gt;The OSM data is stored in &lt;a href=&quot;http://postgis.org&quot;&gt;PostGIS&lt;/a&gt; where we reference it for tile creation and map feature selection. PostGIS (/post&amp;#8217;-jis/) is a spatial extension of the open source &lt;a href=&quot;http://postgresql.org&quot;&gt;PostgreSQL&lt;/a&gt; database. PostGIS essentially adds spatial data types (geometry and geography) and lots (no really, hundreds) of functions to interact with these data types. If your data has a geometry question, PostGIS has one or more functions to answer it. PostGIS has installers for Windows and Mac and even has install packages for various linux flavors. It&amp;#8217;s also not terribly hard to compile the source yourself. Even I&amp;#8217;ve done this, once without cursing.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m creating map tiles with &lt;a href=&quot;http://tilemill.com&quot;&gt;TileMill&lt;/a&gt; from &lt;a href=&quot;http://developmentseed.org/&quot;&gt;Development Seed&lt;/a&gt;. TileMill is a browser based map design studio that can read from various data sources including &lt;a href=&quot;http://www.flickr.com/photos/tarynmarie/218965633/&quot;&gt;shapefiles&lt;/a&gt;, KML, GeoJSON, PostGIS and GeoTIFF. With TileMill you create your map styles with &lt;a href=&quot;https://github.com/mapbox/carto&quot;&gt;Carto&lt;/a&gt;, a CSS-like map styling language that translates to &lt;a href=&quot;http://mapnik.org/&quot;&gt;Mapnik&lt;/a&gt; styles (correct me if I&amp;#8217;m wrong) for super-fast tile rendering. Creating &lt;a href=&quot;http://tiles.mapbox.com/mapbox#!/map/control-room&quot;&gt;beautiful maps&lt;/a&gt; is so easy you&amp;#8217;ll forget all about &lt;a href=&quot;http://www.opengeospatial.org/standards/sld&quot;&gt;SLD&lt;/a&gt;. Recent updates include easy installation for both &lt;a href=&quot;http://mapbox.com/tilemill/docs/manual/&quot;&gt;Mac OS X and Ubuntu&lt;/a&gt; (time to fire up the VMs windows users).&lt;/p&gt;

&lt;p&gt;The product of a TileMill export is an &lt;a href=&quot;http://mapbox.com/mbtiles-spec/&quot;&gt;mbtiles file&lt;/a&gt; which is an open spec for storing tiled map data in a SQLite database. This makes it much easier to transfer millions of map tiles to different locations as a single file, not the z/x/y.png directory hell that is the end result of most tiling jobs. I once vowed to quit map tiling efforts. Then I found TileMill. Anyway, we need a way to serve these tiles in this mbtiles format. Development Seed has another piece of open software for serving these, &lt;a href=&quot;https://github.com/mapbox/tilestream&quot;&gt;TileStream&lt;/a&gt;. You can download the source code for TileStream and build your own service or use a &lt;a href=&quot;http://mapbox.com/#/tilestream&quot;&gt;hosted solution&lt;/a&gt; for a fee and have your map tiles on a globally distributed CDN. Another solution, and the one I chose, is &lt;a href=&quot;http://tilestache.org/&quot;&gt;TileStache&lt;/a&gt; which python-based web application written by &lt;a href=&quot;https://github.com/migurski&quot;&gt;Michal Migurski&lt;/a&gt; that can serve and cache map tiles. With just a few lines of code you can tell TileStache where to find your mbtiles file, what URL to serve them from and where to cache the generated tiles.&lt;/p&gt;

&lt;p&gt;Last but certainly not least is &lt;a href=&quot;http://mapfish.org&quot;&gt;MapFish&lt;/a&gt;. MapFish is a Pylons (python) based application that lets you Create, Read, Update and Delete (CRUD) geographic features via HTTP POST, GET, PUT and DELETEs. For this application, I&amp;#8217;ve extended MapFish to create a select service that simply runs multiple spatial queries against a few layers (bars, cafes, restaurants, bicycle rentals) with just one HTTP request. I&amp;#8217;ve been using MapFish for a while now for a number of projects and highly recommend it.&lt;/p&gt;

&lt;h2&gt;Credit where credit is due&lt;/h2&gt;

&lt;p&gt;In addition to the projects above, there were a number of other resources used that deserve mention.&lt;/p&gt;

&lt;p&gt;The OpenStreetMap data was downloaded from &lt;a href=&quot;http://www.geofabrik.de/&quot;&gt;Geofabrik&lt;/a&gt; who graciously provide &lt;a href=&quot;http://download.geofabrik.de/&quot;&gt;OSM data downloads&lt;/a&gt; to the state level updated &lt;strong&gt;daily&lt;/strong&gt;. In my case it was very simple (and fast) to download just the data for Colorado. What an effort! Thanks Geofabrik.&lt;/p&gt;

&lt;p&gt;The base map tiles come from &lt;a href=&quot;http://mapquest.com&quot;&gt;MapQuest&lt;/a&gt;, who recently as part of their &lt;a href=&quot;http://open.mapquest.com&quot;&gt;Open MapQuest&lt;/a&gt; efforts have released both &lt;a href=&quot;http://developer.mapquest.com/web/products/open/map&quot;&gt;street and aerial maps&lt;/a&gt; free for use, with pretty generous terms. Thanks MapQuest!&lt;/p&gt;

&lt;p&gt;Speaking of OSM, our &lt;a href=&quot;http://www.meetup.com/OSM-Colorado/&quot;&gt;local Denver OSM Meetup Group&lt;/a&gt; have had a few &lt;a href=&quot;http://www.meetup.com/OSM-Colorado/events/25586581/&quot;&gt;recent&lt;/a&gt; &lt;a href=&quot;http://www.meetup.com/OSM-Colorado/events/28960191/&quot;&gt;efforts&lt;/a&gt; to help create a more accurate and complete map of downtown Denver. Thanks.&lt;/p&gt;

&lt;p&gt;A note to local Denver folks: If you see a missing or incorrect bar, cafe, restaurant, etc in the map, update it in OpenStreetMap. I&amp;#8217;ll be pulling fresh OSM data a time or two more before the conference.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Bike to Work Day</title>
    <link href="http://JasonSanford.github.com/2011/bike-to-work-day/"/>
    <updated>2011-06-22T15:01:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/bike-to-work-day</id>
    <content type="html">&lt;p&gt;Today is &lt;a href=&quot;http://www3.drcog.org/biketowork&quot;&gt;Bike to Work Day&lt;/a&gt; so I thought I&amp;#8217;d finally take a stab at biking in. I&amp;#8217;m happy to report I made it &lt;strike&gt;sweaty&lt;/strike&gt; safely to work.&lt;/p&gt;

&lt;p&gt;More importantly, I thought I&amp;#8217;d share an awesome site I&amp;#8217;ve been using lately, &lt;a href=&quot;http://ridewithgps.com/&quot;&gt;RideWithGPS&lt;/a&gt;. A coworker recommended it and I&amp;#8217;ve been really impressed. You can upload your tracks in multiple formats (kml, tcx, gpx) or trace your route on Google Maps. Word on the street is soon they&amp;#8217;ll have even more options for base maps like &lt;a href=&quot;http://osm.org&quot;&gt;OpenStreetMap&lt;/a&gt; and &lt;a href=&quot;http://www.arcgis.com/home/&quot;&gt;ArcGIS Online&lt;/a&gt; (or ArcGIS for the internets, or whatever &amp;#8230;). You can also very easily embed maps like the one below.&lt;/p&gt;

&lt;iframe src=&quot;http://ridewithgps.com/routes/490933/embed&quot; height=&quot;500px&quot; width=&quot;100%&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;

</content>
  </entry>
  
  <entry>
    <title>GeoJSON Tiles With MapFish</title>
    <link href="http://JasonSanford.github.com/2011/geojson-tiles-with-mapfish/"/>
    <updated>2011-05-19T14:35:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/geojson-tiles-with-mapfish</id>
    <content type="html">&lt;h2&gt;Polymaps&lt;/h2&gt;

&lt;p&gt;When SimpleGeo &lt;a href=&quot;http://blog.simplegeo.com/2010/08/20/introducing-polymaps/&quot;&gt;announced Polymaps&lt;/a&gt; back in August the geo community was quick to notice the potential of this modern web mapping library. We could now visualize our vector-based datasets with complex geometry without the need for generating tile sets with staggering numbers of images, only to have to re-generate these tiles as the geometry behind them changes. But this announcement also prompted a few folks to ask the question, &lt;a href=&quot;http://gis.stackexchange.com/questions/3712/create-vector-geojson-tiles-for-polymaps&quot;&gt;&amp;#8220;How do I generate these GeoJSON tiles?&amp;#8221;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are only a few solutions that I know of. &lt;a href=&quot;http://tilestache.org/doc/TileStache.Goodies.Providers.PostGeoJSON.html&quot;&gt;TileStache&lt;/a&gt; is a python-based web application that can stream and cache (I think) GeoJSON tiles among other formats. &lt;a href=&quot;http://www.arc2earth.com/&quot;&gt;Arc2Earth&lt;/a&gt; supports streaming GeoJSON tiles from any datasource in an Arc2Earth or Arc2Cloud instance by using the &amp;#8220;tiles&amp;#8221; endpoint (http://my-a2e-instance.appspot.com/a2e/data/datasources/myDatasource/tiles/{Z}/{X}/{Y}?f=gjson).&lt;/p&gt;

&lt;p&gt;A few projects I&amp;#8217;ve been working on recently have been using &lt;a href=&quot;http://mapfish.org/&quot;&gt;MapFish&lt;/a&gt;, which is an open source framework for creating web mapping applications. MapFish is built on the Pylons web framework and integrates tightly with a number of other open source projects (SQLAlchemy, GeoAlchemy, Shapely). It&amp;#8217;s got two core components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a RIA-oriented JavaScript toolset for the client side (of which I have admittedly zero experience)&lt;/li&gt;
&lt;li&gt;a server framework for creating web services to Create, Read, Update and Delete features (CRUD) via HTTP POST, GET, PUT and DELETEs&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;While pondering home-grown solutions to stream GeoJSON tiles to the client, I realized that MapFish had all of the components needed to perform the conversion of a typical map tile request (http://my-geo-app.com/parcels/14/4516/6477) into a &lt;a href=&quot;http://geojson.org/&quot;&gt;GeoJSON&lt;/a&gt; &lt;a href=&quot;http://geojson.org/geojson-spec.html#feature-collection-objects&quot;&gt;FeatureCollection&lt;/a&gt;, which is what Polymaps needs to display features.&lt;/p&gt;

&lt;h2&gt;The Solution&lt;/h2&gt;

&lt;p&gt;What we need to do is take a layer request that contains a zoom level, an X and a Y coordinate and then somehow create a bounding box in our layer&amp;#8217;s coordinate system (SRID 4326). The first step is to properly route the request to its appropriate controller and action. We can easily do this by editing the routing.py in our MapFish config directory.&lt;/p&gt;

&lt;p&gt;A vector tile request might look like: http://my-mapfish-app.com/my_layer/geojson/14/4516/6477&lt;/p&gt;

&lt;div&gt;&lt;script src=&#8217;https://gist.github.com/963760.js?file=routing.py&#8217;&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;map.connect(&amp;quot;/{controller}/geojson/{z}/{x}/{y}&amp;quot;, controller=&amp;quot;{controller}&amp;quot;, action=&amp;quot;geojson&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;p&gt;Our tile requests should now be forwarded to the &amp;#8220;geojson&amp;#8221; controller. The controller simply takes the request and related variables (Z, X and Y in our case) and calls geojson method of the controller class.&lt;/p&gt;

&lt;div&gt;&lt;script src=&#8217;https://gist.github.com/963760.js?file=layer_controller.py&#8217;&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;    @geojsonify
    def geojson(self, z=False, x=False, y=False):
        &amp;quot;&amp;quot;&amp;quot;GET /{z}/{x}/{y} return features within tile bounds.&amp;quot;&amp;quot;&amp;quot;
        return self.protocol.geojson(request, response, z=z, x=x, y=y)&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;p&gt;Protocol&amp;#8217;s geojson method is really where all of the magic happens. Here we pass our x, y and z variables and, with the help of &lt;a href=&quot;http://trac.gispython.org/lab/wiki/Shapely&quot;&gt;Shapely&lt;/a&gt;, create a Polygon (line 46). This is the bounding box of the requested tile. Now we convert the Shapely polygon into the well known binary geometry we need for the geometry filter (lines 48 - 50). Lastly we combine the attribute and geometry filter, add the &amp;#8220;Access-Control-Allow-Origin: *&amp;#8221; header required for Polymaps and return to MapFish&amp;#8217;s read method that create GeoJSON FeatureCollections from spatial and attribute queries (lines 52 - 58). Most of the code to convert tiled map requests to Lat/Lng bounding boxes comes from &lt;a href=&quot;http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/&quot;&gt;maptiler.org&lt;/a&gt;.&lt;/p&gt;

&lt;div&gt;&lt;script src=&#8217;https://gist.github.com/963760.js?file=protocol.py&#8217;&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;# Imports
import math


# Functions
def TileBounds(tx, ty, zoom):
    # Returns bounds of the given tile in EPSG:4326 coordinates
    
    ty = ((1 &amp;lt;&amp;lt; zoom) - ty - 1)
    
    # Pixels to Meters
    # Converts pixel coordinates in given zoom level of pyramid to EPSG:900913
    originShift = 20037508.342789244
    # resolution = (meters/pixel) for given zoom level (measured at Equator)
    resolution = 156543.03392804062 / (2**zoom)
    minx_meters = ( tx * 256 ) * resolution - originShift
    miny_meters = ( ty * 256 ) * resolution - originShift
    maxx_meters = ( ( tx + 1 ) * 256 ) * resolution - originShift
    maxy_meters = ( ( ty + 1 ) * 256 ) * resolution - originShift

    # Meters to Lat/Lon
    # Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
    minx_ll = (minx_meters / originShift) * 180.0
    miny_ll = (miny_meters / originShift) * 180.0
    maxx_ll = (maxx_meters / originShift) * 180.0
    maxy_ll = (maxy_meters / originShift) * 180.0
    
    miny_ll = 180 / math.pi * (2 * math.atan( math.exp( miny_ll * math.pi / 180.0)) - math.pi / 2.0)
    maxy_ll = 180 / math.pi * (2 * math.atan( math.exp( maxy_ll * math.pi / 180.0)) - math.pi / 2.0)
    
    return Polygon(((minx_ll, miny_ll), (minx_ll, maxy_ll), (maxx_ll, maxy_ll), (maxx_ll, miny_ll),(minx_ll, miny_ll)))


# Action - This is in the Protocol class
def geojson(self, request, response, x=None, y=None, z=None):
        &amp;quot;&amp;quot;&amp;quot; Return features in X/Y/Z tile bounds. &amp;quot;&amp;quot;&amp;quot;
        if not x and y and z:
            abort(404)
            
        x = int(x)
        y = int(y)
        z = int(z)    
        
        geom_column = self.mapped_class.geometry_column()

        geometry = TileBounds(x, y, z)

        wkb_geometry = WKBSpatialElement(buffer(geometry.wkb), 4326)

        geom_filter = within_distance(geom_column, wkb_geometry, 0)

        attr_filter = create_attr_filter(request, self.mapped_class)
        filter = and_(attr_filter, geom_filter)
        
        # Important for Polymaps
        response.headers[&amp;quot;Access-Control-Allow-Origin&amp;quot;] = &amp;quot;*&amp;quot;
        
        return self.read(request, filter)&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;h2&gt;The Fine Print&lt;/h2&gt;

&lt;p&gt;Since I&amp;#8217;m creating a bounding box with Lat/Lng values, your MapFish layer needs to support SRID 4326. There&amp;#8217;s probably an easy work around for this that someone can figure out. But for me this worked as my data was already in SRID 4326.&lt;/p&gt;

&lt;p&gt;Also, we&amp;#8217;re not caching any of these results so that future requests to the same vector tile don&amp;#8217;t require as much overhead. If we were to cache the tiles we&amp;#8217;d lose the ability to add query parameters to further filter our requests.&lt;/p&gt;

&lt;h2&gt;Performance Notes&lt;/h2&gt;

&lt;p&gt;Streaming GeoJSON tiles to the client can produce some pretty nice visualizations, but there are a few things to think about. Lots of bytes are traveling from the server to your web app and you&amp;#8217;ll want to shave off every 1 or 0 you can.&lt;/p&gt;

&lt;p&gt;By default MapFish returns not only the GeoJSON geometry for a feature, but also a &lt;a href=&quot;http://geojson.org/geojson-spec.html#bounding-boxes&quot;&gt;bounding box&lt;/a&gt;. For me it made sense to alter the source code to omit this extra (unnecessary in my case) geometry.&lt;/p&gt;

&lt;p&gt;You&amp;#8217;d also do yourself a favor to eliminate as many feature properties as you can. You might not think removing a handful of properties would make much of a difference, but when you&amp;#8217;re returning scores of features within each map tile, these start to add up quickly.&lt;/p&gt;

&lt;p&gt;The real beauty behind streaming these vector tiles is that you can simplify the geometry at the lower zoom levels but return to the full detailed geometry at the higher zoom levels. This makes sure we remove as many vertices we can when dealing with large numbers of features. I&amp;#8217;ve left out the code for the zoom-dependent geometry simplification in this blog post to keep things as simple as possible, but feel free to contact me to get more information.&lt;/p&gt;

&lt;h2&gt;OK, Show Me&lt;/h2&gt;

&lt;p&gt;Check out the &lt;del&gt;Tiled GeoJSON demo&lt;/del&gt;* to see things in action. Remember that since we can still pass url parameters to the MapFish back-end, you can adjust the range for a few of the layer attributes.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://JasonSanford.github.com/images/posts/full/geojson-tiles-url-params.png&quot; title=&quot;&quot; &gt;&lt;/p&gt;

&lt;p&gt;* Sorry, no longer available. I&amp;#8217;m tired of paying my AWS bill.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>CharlotteJS Meetup Slides, Demos and Code</title>
    <link href="http://JasonSanford.github.com/2011/charlottejs-meetup-slides-demos-and-code/"/>
    <updated>2011-04-21T14:15:00-06:00</updated>
    <id>http://JasonSanford.github.com/2011/charlottejs-meetup-slides-demos-and-code</id>
    <content type="html">&lt;p&gt;I had a great time tonight at the &lt;a href=&quot;http://www.charlottejs.org/events/16689428/&quot;&gt;CharlotteJS Meetup&lt;/a&gt;. Working from home for the last few months has made me appreciate opportunities to connect with developers face to face. I&amp;#8217;ll have to try to make it to as many of these meetups that I can before the big move.&lt;/p&gt;

&lt;p&gt;I thought I&amp;#8217;d share my slides and link to the demos I showed at my talk.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/charlotte-js-meetup/&quot;&gt;CharlotteJS Meetup Slides&lt;/a&gt; (warning: each slide is a 1024x768 png, so be patient)&lt;/p&gt;

&lt;h2&gt;Demo Links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://gisapps.co.union.nc.us/community-mapper/&quot;&gt;Union County Community Mapper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://maps.co.mecklenburg.nc.us/geoportal/&quot;&gt;Mecklenburg County GeoPortal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://open-data-day.geojason.info/&quot;&gt;Open Data Day Hack (Mecklenburg County Building Permit Search)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Code&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/JasonSanford/open-data-day-hack&quot;&gt;Open Data Day Hack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/JasonSanford/GeoJSON-to-Google-Maps&quot;&gt;GeoJSON to Google Maps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://code.google.com/p/geoportal/&quot;&gt;GeoPortal front end&lt;/a&gt;, &lt;a href=&quot;http://code.google.com/p/postgis-restful-web-service-framework/&quot;&gt;GeoPortal back end&lt;/a&gt; (written by &lt;a href=&quot;http://fuzzytolerance.info/&quot;&gt;Tobin Bradley&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://postgis.org/&quot;&gt;PostGIS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://polymaps.org/&quot;&gt;Polymaps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://mapfish.org/&quot;&gt;MapFish&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  
  <entry>
    <title>My NC GIS Slides</title>
    <link href="http://JasonSanford.github.com/2011/my-nc-gis-slides/"/>
    <updated>2011-02-21T14:05:00-07:00</updated>
    <id>http://JasonSanford.github.com/2011/my-nc-gis-slides</id>
    <content type="html">&lt;p&gt;The &lt;a href=&quot;http://www.cgia.state.nc.us/ncgis2011&quot;&gt;2011 North Carolina GIS Conference&lt;/a&gt; was last Thursday and Friday in Raleigh, NC. It was a great conference with a well-balanced program of technical and non-technical talks. I spoke about using the Google Maps API in local government. Feel free to &lt;a href=&quot;http://geojason.info/nc-gis-slides/&quot;&gt;view my slides&lt;/a&gt; but don&amp;#8217;t get too excited as a lot of them are simple images and lack context. It might take some time for each slide to load over a slow connection as each one is a 1024x768 png, so click once and be patient. Enjoy!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/nc-gis-slides/&quot;&gt;NC GIS 2011 slides&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Open Data Day Hack</title>
    <link href="http://JasonSanford.github.com/2010/open-data-day-hack/"/>
    <updated>2010-12-13T13:35:00-07:00</updated>
    <id>http://JasonSanford.github.com/2010/open-data-day-hack</id>
    <content type="html">&lt;p&gt;Dec 4&lt;sup&gt;th&lt;/sup&gt; was Open Data Day and coders across the globe were pushing, pulling, analyzing and scraping open data. Spare time has been hard to come by recently so I&amp;#8217;m a little late to the party, but I&amp;#8217;m happy with the outcome. I thought I&amp;#8217;d share what I came up with and how it all came together.&lt;/p&gt;

&lt;h2&gt;So, what is it?&lt;/h2&gt;

&lt;p&gt;I created a Google Maps based application that lets users query Mecklenburg County, NC (Charlotte) building permits by location and a number of other parameters. Want to know how many building permits were pulled around 2319 Providence Rd? Sure. Only concerned with permits pulled in 2009? Filter by date. Only interested in finding the new &lt;a href=&quot;http://en.wikipedia.org/wiki/McMansion&quot;&gt;McMansions&lt;/a&gt; in the neighborhood? Filter by square footage.&lt;/p&gt;

&lt;h2&gt;How does it work?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/open-data-day-distance-widget.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/open-data-day-distance-widget.png&quot; title=&quot;Adjust Search Area&quot; &gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Users determine their search location by either entering an address or clicking the map. Setting the search location drops a marker on the map surrounded by a circular search area. This circle size can be easily changed to query a smaller or larger area. I limit the search area to a maximum radius of 2.5 km to keep the number of results from getting out of hand. My original design adjusted the search area with another slider in the left panel but I found that adjusting the size on the map was much more intuitive.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/open-data-day-filter-params.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/open-data-day-filter-params.png&quot; title=&quot;Filter results via three parameters&quot; &gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once results are visible, we can narrow these down by a number of different parameters found on the left panel of the application. Currently you can filter by a range of square footage, project cost or permit issue date. I find that using sliders is much simpler that typing discrete values of upper and lower bounds. I can also limit the input range for parameters to keep users from searching for project costs with negative numbers. I made sure to style the &amp;#8220;active&amp;#8221; filters with a bolder look and a drop shadow (sorry IE) to let users know what filters they were using.&lt;/p&gt;

&lt;p&gt;To get project details, users can click a marker and the results on the right side of the page should scroll to the corresponding building permit and highlight it. For now I&amp;#8217;m showing fairly limited information but this could be easily expanded to show more or a link could be added to show full building permit information (I&amp;#8217;m not sure if Mecklenburg County exposes this).&lt;/p&gt;

&lt;h2&gt;Under the hood&lt;/h2&gt;

&lt;p&gt;So it&amp;#8217;s obvious I&amp;#8217;m using Google Maps, nothing new here. With the latest release Google now allows you to animate your markers as they are added to the map. This is how I&amp;#8217;m dropping/bouncing them onto the page. It took me a while to decide if this was tacky or cool. I chose cool.&lt;/p&gt;

&lt;p&gt;This distance widget came from a &lt;a href=&quot;http://code.google.com/apis/maps/articles/mvcfun.html&quot;&gt;Fun with MVC Objects article&lt;/a&gt; written by Luke Mahe from the Google Geo team. This is really where a lot of the magic happens. If I would have had to write this myself it would have taken much longer to push out this quick hack.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m sure a lot of you will notice right off the bat that I&amp;#8217;m using &lt;a href=&quot;http://jqueryui.com/&quot;&gt;jQuery UI for the sliders&lt;/a&gt;. It&amp;#8217;s too easy not to.&lt;/p&gt;

&lt;p&gt;As far as the &amp;#8220;Open Data&amp;#8221; goes, I&amp;#8217;m pulling everything from &lt;a href=&quot;http://maps.co.mecklenburg.nc.us/dataportal/&quot;&gt;Mecklenburg County&amp;#8217;s DataPortal&lt;/a&gt; which was &lt;a href=&quot;http://fuzzytolerance.info/code/making-a-data-portal-with-wordpress/&quot;&gt;recently released&lt;/a&gt; to easily share spatial data. From here users can connect to WMS services, download KML, or link into the GIS Data Center to download data in &lt;a href=&quot;http://en.wikipedia.org/wiki/Shapefile&quot;&gt;other formats&lt;/a&gt;. But I prefer to pull straight from &lt;a href=&quot;http://maps.co.mecklenburg.nc.us/rest/&quot;&gt;a series of RESTful Web Services&lt;/a&gt; that are powered by a &lt;a href=&quot;http://code.google.com/p/postgis-restful-web-service-framework/&quot;&gt;great open source project&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Ok, show me.&lt;/h2&gt;

&lt;p&gt;View the application live at &lt;a href=&quot;http://open-data-day.geojason.info&quot;&gt;http://open-data-day.geojason.info&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also created a short &lt;a href=&quot;http://screenr.com/eMq&quot;&gt;screen cast&lt;/a&gt; showing it in action.&lt;/p&gt;

&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; width=&quot;560&quot; height=&quot;345&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;&lt;param name=&quot;flashvars&quot; value=&quot;i=143210&quot; /&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;&lt;param name=&quot;src&quot; value=&quot;http://screenr.com/Content/assets/screenr_1116090935.swf&quot; /&gt;&lt;param name=&quot;allowfullscreen&quot; value=&quot;true&quot; /&gt;&lt;embed type=&quot;application/x-shockwave-flash&quot; width=&quot;560&quot; height=&quot;345&quot; src=&quot;http://screenr.com/Content/assets/screenr_1116090935.swf&quot; flashvars=&quot;i=143210&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/embed&gt;&lt;/object&gt;

</content>
  </entry>
  
  <entry>
    <title>GeoJSON to Google Maps Utility</title>
    <link href="http://JasonSanford.github.com/2010/geojson-to-google-maps-utility/"/>
    <updated>2010-10-04T13:29:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/geojson-to-google-maps-utility</id>
    <content type="html">&lt;p&gt;A few months back I posted code on my demo page for converting GeoJSON polygons to Google Maps polygons. Since then I&amp;#8217;ve needed to create similar code for points and lines as well. I&amp;#8217;ve pulled all of them together and pushed them to &lt;a href=&quot;https://github.com/JasonSanford/GeoJSON-to-Google-Maps&quot;&gt;GitHub&lt;/a&gt;. This should work for most (all?) GeoJSON types.&lt;/p&gt;

&lt;h2&gt;A quick example&lt;/h2&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;12&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;13&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;14&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;15&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;16&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;17&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;18&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;19&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;geojson&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;  &lt;span class=&quot;s2&quot;&gt;&amp;quot;type&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;LineString&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;  &lt;span class=&quot;s2&quot;&gt;&amp;quot;coordinates&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;80.661983228058659&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;35.042968081213758&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;80.662076494242413&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;35.042749414542243&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;80.662196794397431&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;35.042626481357232&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;80.664238981504525&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;35.041175532632963&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;googleOptions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;strokeColor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;#FFFF00&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;strokeWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;strokeOpacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.75&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;googleVector&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;GeoJSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;geojson&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;googleOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;googleVector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setMap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;See my &lt;a href=&quot;https://github.com/JasonSanford/GeoJSON-to-Google-Maps&quot;&gt;GeoJSON to Google Maps GitHub repository&lt;/a&gt; for &amp;#8220;full&amp;#8221; documentation and a demo page. I&amp;#8217;m sure there&amp;#8217;s room for improvement so feel free to fork it and notify me of any changes.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Line Length and Polygon Area in Google Maps API V3</title>
    <link href="http://JasonSanford.github.com/2010/line-length-and-polygon-area-in-google-maps-api-v3/"/>
    <updated>2010-07-06T13:08:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/line-length-and-polygon-area-in-google-maps-api-v3</id>
    <content type="html">&lt;p&gt;This post used to show a way to measure length and area with the Google Maps API before there was support for such a thing. This involved much the same method of creating line and polygon shapes on the map for measuring length and area, but used a web service to do the measuring. Very clunky. Very unnecessary now.&lt;/p&gt;

&lt;p&gt;Now that this is part of the API, I&amp;#8217;m simply &lt;a href=&quot;http://JasonSanford.github.com/demos/line-length-polygon-area-google-maps-v3&quot;&gt;linking to demo&lt;/a&gt; of how to create a quick and easy measuring tool for Google Maps. Click the image below to view the demo.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/demos/line-length-polygon-area-google-maps-v3&quot;&gt;&lt;img class=&quot;center&quot; src=&quot;http://JasonSanford.github.com/images/posts/full/google-maps-measure.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Stack Overflow for GIS</title>
    <link href="http://JasonSanford.github.com/2010/stack-overflow-for-gis/"/>
    <updated>2010-06-02T13:00:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/stack-overflow-for-gis</id>
    <content type="html">&lt;h2&gt;Out of Office&lt;/h2&gt;

&lt;p&gt;After posting a response to a question on a local &lt;a href=&quot;http://lists.unc.edu/read/?forum=ncgis&quot;&gt;GIS Listserv&lt;/a&gt; and getting ten or so out of office emails, I thought to myself &amp;#8220;There&amp;#8217;s got to be a better way.&amp;#8221; Coincidently, a few minutes later I stumbled on a proposal for a &lt;a href=&quot;http://area51.stackexchange.com/proposals/1425/geographic-information-systems&quot;&gt;Stack Overflow site for GIS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you&amp;#8217;re not familiar with &lt;a href=&quot;http://stackoverflow.com/&quot;&gt;Stack Overflow&lt;/a&gt; it&amp;#8217;s basically a free, community driven site for programmers to ask and answer programming related questions.&lt;/p&gt;

&lt;h2&gt;Why do programmers get to have all the fun?&lt;/h2&gt;

&lt;p&gt;The creators of Stack Overflow have started &lt;a href=&quot;http://area51.stackexchange.com/&quot;&gt;Stack Exchange&lt;/a&gt; which allows a group of people to create their own question and answer site about any topic from horses to handbags if there is enough interest.&lt;/p&gt;

&lt;h2&gt;Really? Another GIS forum?&lt;/h2&gt;

&lt;p&gt;You might be thinking, &amp;#8220;Aren&amp;#8217;t there already dozens of GIS help forums out there now?&amp;#8221; Yes, there are. But if you&amp;#8217;ve ever used Stack Overflow you&amp;#8217;ve probably noticed the high quality of questions and answers on the site. Stack Overflow rewards users who visit often, ask questions and propose answers with &amp;#8220;reputation.&amp;#8221; The more reputation you have the more rights you have to edit the site&amp;#8217;s content, questions, answers, etc.&lt;/p&gt;

&lt;h2&gt;Do it!&lt;/h2&gt;

&lt;p&gt;If this interests you I encourage you to visit the &lt;a href=&quot;http://area51.stackexchange.com/proposals/1425/geographic-information-systems&quot;&gt;proposed GIS Stack Exchange&lt;/a&gt; and get involved.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Overlay Map Management With Google Maps API V3</title>
    <link href="http://JasonSanford.github.com/2010/overlay-map-management-with-google-maps-api-v3/"/>
    <updated>2010-05-11T12:27:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/overlay-map-management-with-google-maps-api-v3</id>
    <content type="html">&lt;p&gt;Google Maps API v3 is a complete overhaul of the API v2 and is &lt;a href=&quot;http://code.google.com/apis/maps/documentation/v3/&quot;&gt;specifically designed to be faster&lt;/a&gt; and more applicable to mobile devices. Because of this some of the functionality from v2 isn&amp;#8217;t available. For example with v2 removing all overlays from your map was as simple as calling the &lt;code&gt;clearOverlays()&lt;/code&gt; method on your GMap object. At v3 developers are required to keep track of map overlays which includes Markers, Polygons, ImageMapTypes, etc. Gone are the days of creating random markers and using &lt;code&gt;clearOverlays()&lt;/code&gt; to clean things up.&lt;/p&gt;

&lt;p&gt;I have a project that deals specifically with ImageMapTypes being served from &lt;a title=&quot;GeoWebCache&quot; href=&quot;http://geowebcache.org/trac&quot;&gt;GeoWebCache&lt;/a&gt;. I needed a way to control layer visibility but with v3 there is no &lt;code&gt;clearOverlays()&lt;/code&gt; method to hide these. My solution was to create an array to store the ImageMapTypeOptions for each layer.&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;12&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;13&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;14&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;15&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;16&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;overlayMaps&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;getTileUrl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;zoom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://gisapps.co.union.nc.us:8080/geoserver/gwc/service/gmaps?layers=uc%3Afema_flood_zones&amp;amp;zoom=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;zoom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;x=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;y=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;format=image/png8&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;tileSize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;isPng&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;getTileUrl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;zoom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://gisapps.co.union.nc.us:8080/geoserver/gwc/service/gmaps?layers=uc%3Asubdivisions&amp;amp;zoom=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;zoom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;x=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;y=&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;coord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;amp;format=image/png8&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;tileSize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;isPng&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Once the page is loaded I loop through my overlayMaps array and push a null object into the map&amp;#8217;s overlayMapTypes array for each item. These serve as placeholders for my ImageMapTypes.&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;overlayMaps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;overlayMapTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;So, we&amp;#8217;ve got our placeholders for our overlay maps. How do we create the ImageMapTypes and toggle their visibility? I have some checkboxes with ids that correspond to the order of objects in our overlayMaps array.&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;html&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;checkbox&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;layer&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Flood Zones&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;checkbox&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;layer&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Subdivisions&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;With some help from jQuery we handle the click events from these checkboxes and determine if they were checked or unchecked. If checked, we create a new ImageMapType. Otherwise, we remove it by setting the value to null.&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;.layer&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;layerID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;checked&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;overlayMap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ImageMapType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;overlayMaps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;layerID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;overlayMapTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setAt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;layerID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;overlayMap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;overlayMapTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;overlayMapTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setAt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;layerID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;I &lt;a href=&quot;http://demos.geojason.info/overlay-map-management-google-maps-demo.php&quot;&gt;set up a demo&lt;/a&gt; so you can see it all come together. There&amp;#8217;s a little more code documentation there in case what I&amp;#8217;m doing here doesn&amp;#8217;t make sense.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m sure this probably isn&amp;#8217;t the most efficient way of managing overlays but it worked for me. I welcome any comments or suggestions.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Moving From ArcGIS Server to Google Maps API</title>
    <link href="http://JasonSanford.github.com/2010/moving-from-arcgis-server-to-google-maps-api/"/>
    <updated>2010-04-21T16:46:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/moving-from-arcgis-server-to-google-maps-api</id>
    <content type="html">&lt;p&gt;As mentioned in a &lt;a href=&quot;http://geojason.info/2010/04/map-and-polygon-click-events-google-maps-api/&quot;&gt;previous post&lt;/a&gt; I have been converting Union County&amp;#8217;s &lt;a href=&quot;http://gisapps.co.union.nc.us/community-mapper&quot;&gt;Community Mapper&lt;/a&gt; application from ArcGIS Server to the Google Maps API.&lt;/p&gt;

&lt;h2&gt;Why?&lt;/h2&gt;

&lt;p&gt;Do I have anything against an ArcGIS Server solution? Not at all. ArcGIS Server still takes up a lot of room in my tool chest. I just wanted to freshen up the look and feel of a stale application and take a deep dive into the ever-changing API v3.&lt;/p&gt;

&lt;h2&gt;Benefits&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Let Google handle&lt;/strong&gt; the base map and related traffic. Forget scheduling a map caching job to run for hours (and hours, and hours) every week.&lt;/p&gt;

&lt;p&gt;Users are &lt;strong&gt;comfortable&lt;/strong&gt; with Google Maps. Web mapping trends show Google Maps &lt;a href=&quot;http://weblogs.hitwise.com/us-heather-hopkins/2009/02/google_maps_edges_closer_to_ma_1.html&quot;&gt;continues to catch&lt;/a&gt; (surely have surpassed by now) MapQuest.&lt;/p&gt;

&lt;p&gt;The Google Maps API is &lt;strong&gt;powerful&lt;/strong&gt; and has an &lt;a href=&quot;http://groups.google.com/group/google-maps-js-api-v3&quot;&gt;active community&lt;/a&gt; developing applications with it. Got a question? Send it to the group and you&amp;#8217;ll get replies within hours, maybe minutes.&lt;/p&gt;

&lt;h2&gt;Disadvantages&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/no-roads.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/no-roads.png&quot; title=&quot;These roads were absent on picture day&quot; &gt;&lt;/a&gt;The biggest downer that I see is that you &lt;strong&gt;lose complete control&lt;/strong&gt; over your base map. Sure Google lets your &lt;a href=&quot;http://maps.google.com/support/bin/answer.py?hl=en&amp;amp;amp;answer=98014&quot;&gt;report a problem&lt;/a&gt; but there is no guarantee when, or even if, they&amp;#8217;ll get around to fixing it. Luckily the Street View crew made it around to a good third or so of Union County so our base map isn&amp;#8217;t in bad shape.&lt;/p&gt;

&lt;p&gt;With Google there&amp;#8217;s always a chance of &lt;strong&gt;advertisements&lt;/strong&gt; popping in at some point in the future. Personally, I have no problem with spatially relevant advertising. That&amp;#8217;s the price we pay for someone hosting and updating your web map services. Although, end users might not like the idea of an ad for Jim&amp;#8217;s Tire and Lube appearing near their parcel ownership information.&lt;/p&gt;

&lt;h2&gt;How does it work?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/community-mapper-autocomplete.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/community-mapper-autocomplete.png&quot; title=&quot;One Big Search&quot; &gt;&lt;/a&gt;Users select one or many parcels by either clicking the map or using a single search text box. This eliminates the need for having a text box for every type of search a user might use (owner name, parcel number, subdivision, address, etc). With some simple logic on the back end we can query only the tables whose data matches what the user entered. For example: if a user types &amp;#8220;8620 Elmsworth&amp;#8221; we can be almost certain they are searching for an address. In this case only one table is queried. Alternatively if a user types &amp;#8220;Poplin&amp;#8221; they could be searching for Poplin Elementary School, the Poplin Farms subdivision, or Poplin Rd. In this scenario more tables are queried for potential results but I haven&amp;#8217;t heard any complaining from Postgres yet.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://JasonSanford.github.com/images/posts/full/community-mapper-infowindow.png&quot;&gt;&lt;img class=&quot;left&quot; src=&quot;http://JasonSanford.github.com/images/posts/thumbs/community-mapper-infowindow.png&quot; title=&quot;Spatially Relevant Information&quot; &gt;&lt;/a&gt;Once parcels are selected a user can uncover lots of spatial data by clicking various tabs within an info window. Questions like &amp;#8220;What school district am I in?&amp;#8221;, &amp;#8220;What flood zones are on my property?&amp;#8221; and &amp;#8220;Where are my closest parks, libraries and bus stops located?&amp;#8221; are just a few mouse clicks away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On the front end&lt;/strong&gt; mapping is handled by the Google Maps API (obviously). I&amp;#8217;m using a few JavaScript libraries as well. jQuery makes coding by browser unnecessary and &lt;a href=&quot;http://api.jquery.com/jQuery.getJSON/&quot;&gt;makes HTTP requests a breeze&lt;/a&gt;. &lt;a href=&quot;http://flowplayer.org/tools/index.html&quot;&gt;jQuery Tools&lt;/a&gt; helps out with some simple tabs and modal overlays and is a much lighter weight UI tool than &lt;a href=&quot;http://jqueryui.com/&quot;&gt;jQuery UI&lt;/a&gt;. For all that autocomplete goodness, the folks over at Devbridge have put together a powerful, yet very simple &lt;a href=&quot;http://www.devbridge.com/projects/autocomplete/jquery/&quot;&gt;jQuery autocomplete plugin&lt;/a&gt;. &lt;a href=&quot;http://layout.jquery-dev.net/&quot;&gt;jQuery Layout&lt;/a&gt; keeps things orderly and helps with some nice collapsible panels. Okay, maybe I went a little overkill on the JS libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On the back end&lt;/strong&gt; I&amp;#8217;m using Union County&amp;#8217;s &lt;a href=&quot;http://gisapps.co.union.nc.us/ws/rest&quot;&gt;GeoData API&lt;/a&gt; to do all of my spatial analysis. These are a series of RESTful web services that allow you to execute spatial queries on a PostgreSQL/PostGIS database through simple HTTP requests. I won&amp;#8217;t go into detail here but feel free to check out the documentation for a better explanation.&lt;/p&gt;

&lt;p&gt;A few other new features to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;parcel export in kml, csv and xml formats&lt;/li&gt;
&lt;li&gt;add to your current parcel selection by holding ctrl and clicking the map&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Where&amp;#8217;s it at?&lt;/h2&gt;

&lt;p&gt;The old Community Mapper is actually still live but users can choose to try out the new application while I work out a few kinks with the newer version.&lt;/p&gt;

&lt;p&gt;Community Mapper &lt;sup&gt;1.0&lt;/sup&gt; - &lt;a href=&quot;http://gisapps.co.union.nc.us/cm&quot;&gt;http://gisapps.co.union.nc.us/cm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Community Mapper &lt;sup&gt;2.0 &lt;/sup&gt; - &lt;a href=&quot;http://gisapps.co.union.nc.us/community-mapper&quot;&gt;http://gisapps.co.union.nc.us/community-mapper&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions or comments about the application or you get some errors feel free to &lt;a href=&quot;mailto:jason@geojason.info&quot;&gt;let me know&lt;/a&gt;. Styling and documentation are lacking as these are the last things I&amp;#8217;ll be working on.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Refcardz, Get your Refcardz</title>
    <link href="http://JasonSanford.github.com/2010/refcardz-get-your-refcardz/"/>
    <updated>2010-04-12T16:38:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/refcardz-get-your-refcardz</id>
    <content type="html">&lt;p&gt;For those that haven&amp;#8217;t found them yet, &lt;a href=&quot;http://refcardz.dzone.com/&quot;&gt;DZone&amp;#8217;s Refcardz&lt;/a&gt; can be an extremely helpful tool for developers.  Each Refcard gives a brief overview of a particular piece of technology whether it&amp;#8217;s a broad topic like &lt;a href=&quot;http://refcardz.dzone.com/refcardz/getting-started-cloud&quot;&gt;Getting Started with Cloud Computing&lt;/a&gt; or one of my favorites &lt;a href=&quot;http://refcardz.dzone.com/refcardz/essential-postgresql&quot;&gt;Essential PostgreSQL&lt;/a&gt;. I plan on reading up on the &lt;a href=&quot;http://refcardz.dzone.com/refcardz/getting-started-git&quot;&gt;Getting Started with Git Refcard&lt;/a&gt;, which came out today.&lt;/p&gt;

&lt;p&gt;Now that Google Docs can take almost any file type I just upload the Refcardz I use the most. This way I can always get to them if I&amp;#8217;m in a bind and don&amp;#8217;t want to log in to DZone to download them again or share them with friends.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Map and Polygon Click Events in Google Maps API v3</title>
    <link href="http://JasonSanford.github.com/2010/map-and-polygon-click-events-google-maps-api/"/>
    <updated>2010-04-10T14:36:00-06:00</updated>
    <id>http://JasonSanford.github.com/2010/map-and-polygon-click-events-google-maps-api</id>
    <content type="html">&lt;h2&gt;A little Background&lt;/h2&gt;

&lt;p&gt;I&amp;#8217;ve been working on a project at work converting our &lt;a href=&quot;http://gisapps.co.union.nc.us/cm&quot;&gt;Community Mapper&lt;/a&gt; application from an &lt;a href=&quot;http://resources.esri.com/arcgisserver/apis/javascript/arcgis/index.cfm?fa=home&quot;&gt;ArcGIS API for JavaScript&lt;/a&gt; front end to a &lt;a href=&quot;http://code.google.com/apis/maps/documentation/v3/reference.html&quot;&gt;Google Maps API v3&lt;/a&gt; front end. One of the requirements of the project was that both the map and dynamically drawn polygons respond to click events.&lt;/p&gt;

&lt;p&gt;Registering these events is easy enough:&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;mapClick&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;click&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;myIdentifyFunction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;polygonClick&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;polygon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;click&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;ShowInfoWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;h2&gt;The Problem&lt;/h2&gt;

&lt;p&gt;Little did I know that when I click a polygon the map &amp;#8216;click&amp;#8217; event is also triggered.  This is not the case with markers.&lt;/p&gt;

&lt;h2&gt;The Solution&lt;/h2&gt;

&lt;p&gt;What I needed to do was to un-register the map&amp;#8217;s &amp;#8216;click&amp;#8217; event when I click a polygon.  I quickly figured out that I wouldn&amp;#8217;t be able to do this with the polygon&amp;#8217;s click event but would have to listen for the &amp;#8216;mousedown&amp;#8217; event, show my infowindow, then remove the map &amp;#8216;click&amp;#8217; listener, then re-attach the map &amp;#8216;click&amp;#8217; listener when the user &amp;#8216;mouseup&amp;#8217;s on the polygon.  Actually in the code below you&amp;#8217;ll see that I delayed the re-attachment of the map &amp;#8216;click&amp;#8217; event by 200 milliseconds to ensure that the function called in the polygon &amp;#8216;click&amp;#8217; event has been triggered.&lt;/p&gt;

&lt;figure class=&#8217;code&#8217;&gt; &lt;div class=&quot;highlight&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre class=&quot;line-numbers&quot;&gt;&lt;span class=&#8217;line-number&#8217;&gt;1&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;2&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;3&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;4&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;5&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;6&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;7&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;8&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;9&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;10&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;11&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;12&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;13&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;14&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;15&lt;/span&gt;
&lt;span class=&#8217;line-number&#8217;&gt;16&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&#8217;code&#8217;&gt;&lt;pre&gt;&lt;code class=&#8217;js&#8217;&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;mapClick&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;click&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;MyIdentifyFunction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;polygonMousedown&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;polygon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;mousedown&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;ShowInfoWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;removeListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;mapClick&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;nx&quot;&gt;polygonMouseup&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;polygon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;mouseup&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;nx&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;nx&quot;&gt;mapClick&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;maps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;click&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;            &lt;span class=&quot;nx&quot;&gt;MyIdentifyFunction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;evt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class=&#8217;line&#8217;&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;The problem with this solution is that because I show the infowindow on mousedown this could be triggered if a user is trying to pan the map by clicking and dragging within a polygon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2010-07-22)&lt;/strong&gt; -  The API has changed so that the polygons capture the click event. You shouldn&amp;#8217;t have to use this solution any longer&lt;/p&gt;
</content>
  </entry>
  
</feed>
