1. michael b
  2. otf-mapsmashup

Commits

michaelb  committed b3b4b88 Draft

disabling goecoding for now

  • Participants
  • Parent commits 9383ca5
  • Branches default

Comments (0)

Files changed (2)

File index.html

View file
 
 window.onerror = function(error, url, line) {
 		$('.spinner').replaceWith("<strong>Error " + line + ":</strong> " + error);
-		controller.sendLog({acc:'error', data:'ERR:'+error+' URL:'+url+' L:'+line});
 };
+</script>
 
-var add_spots = function (feature_list) {
-    var geoJson = {
-        type: 'FeatureCollection',
-        features: feature_list,
-    };
-
-    //var map = L.mapbox.map('map', 'examples.map-liczq28b')
-    var map = L.mapbox.map('map', 'examples.map-20v6611k')
-        // Sets the initial map view to 0.1296E, 51.5011N @ Z14.
-        .setView([39.7292, -104.942], 4);
-        //.setView([39.12367, -76.81229], 9);
-
-    var ATTR_FILTER_CAT = 'data-filtercat';
-
-    var clean = function (s) {
-        return s.toLowerCase().replace(/\s+/g, '');
-    };
-
-    var filter_by_me = function (e) {
-        $('#filters').find('a').removeClass('active');
-        $(e).addClass('active');
-        var cat = clean($(e).attr(ATTR_FILTER_CAT) || ''); // Meow! =^_^=
-        map.markerLayer.setFilter(function(f) {
-            return cat === '*' || clean(f.properties.row.category) === cat;
-        });
-    };
-
-    // Add custom popups to each using our custom feature properties
-    map.markerLayer.on('layeradd', function(e) {
-        var marker = e.layer,
-            feature = marker.feature,
-            row = feature.properties.row;
-
-        // Create custom popup content
-        var popupContent =  [
-                        '<div class="popup-info">',
-                            '<p class="title"><strong>', row.title, '</strong></p>',
-                            '<p class="category">', row.category, '</p>',
-                            '<p><tt class="addres">',
-                                row.addressline1, "<br />",
-                                row.addressline2 || row.addresssline2,
-                                '</tt></p>',
-                        '</div>'
-                    ].join(' ');
-
-        // http://leafletjs.com/reference.html#popup
-        marker.bindPopup(popupContent, {
-            closeButton: true,
-            minWidth: 320
-        });
-
-        var cat = clean(row.category);
-
-        // No category of note
-        if (!cat || cat.length < 1) {
-            return;
-        }
-        var $b = $('#filters ['+ATTR_FILTER_CAT+'='+cat+']');
-        if ($b.length < 1) {
-            // If the layer button does not exist add it
-            var li = [
-                    "<li><a href='#' ", ATTR_FILTER_CAT, "='", cat,"'>",
-                    row.category,"</a></li>"].join("")
-            $('#filters').append(li)
-        }
-    });
-
-
-    $('#filters').on('click', 'a', function () {
-            filter_by_me(this);
-        });
-    map.markerLayer.setGeoJSON(geoJson);
-
-    $('img.spinner').fadeOut();
-    $('#map_ui').show();
-};
-
-$('document').ready(function () {
-    var GEOCODE_API = 'http://maps.googleapis.com/maps/api/geocode/json';
-    var fetched = 0;
-    var geojson = [];
-
-    var push = function (row) {
-        geojson.push({
-                type: 'Feature',
-                geometry: {
-                    type: 'Point',
-                    coordinates: [row.geolongitude, row.geolatitude]
-                },
-                properties: {
-                    'marker-color': '#CC0033',
-                    title: row.title,
-                    row: row
-                }
-            });
-
-    };
-
-    var fetch = function (i, data) {
-        var row = data[i];
-
-        var next = function () {
-            // Fetch next if there are some left
-            if (i+1 < data.length) {
-                fetch(i+1, data);
-            } else {
-                add_spots(geojson);
-            }
-        };
-
-        if (row.geolatitude) {
-            // Already filled out by google docs, just append right now
-            push(row);
-            next();
-        } else {
-            // Manually fill out
-						var address = row['addressline1'] + ' ' + (row.addressline2 || row.addresssline2 || '');
-
-            $.get(GEOCODE_API, {
-                        address: address,
-                        sensor: false
-                    }, function (a) {
-												if (!a.results) {
-														// sometimes is not pre-parsed, parse now
-														a = $.parseJSON(a);
-												}
-
-                        // Add lat / longitude data to row
-                        if (a.results && a.results.length > 0) {
-                            // There were results, cool!
-                            var loc = a.results[0].geometry['location'];
-                            row.geolongitude = loc.lng;
-                            row.geolatitude = loc.lat;
-                            push(row);
-                            //console.info("FOUND!", address, row, a);
-                        } else {
-                            console.error("Could not find lat/lon for ", address, a);
-                        }
-                        next();
-                    });
-        }
-    };
-
-    Tabletop.init( {
-                //key: 'https://docs.google.com/spreadsheet/pub?key=0Aj7WbjRT9mlmdFd4RHY0ZklncnRObnMzMU1xaW5vTXc&output=html',
-                key: VARS.spreadsheet,
-                simpleSheet: true,
-                callback: function (data, tabletop) {
-                    //console.log(data);
-                    fetch(0, data);
-                }
-            } )
-
-});
-</script>
+<script src='map_script.js'></script>
 
 </body>
 </html>

File map_script.js

View file
+
+var add_spots = function (feature_list) {
+    var geoJson = {
+        type: 'FeatureCollection',
+        features: feature_list,
+    };
+
+    //var map = L.mapbox.map('map', 'examples.map-liczq28b')
+    var map = L.mapbox.map('map', 'examples.map-20v6611k')
+        // Sets the initial map view to 0.1296E, 51.5011N @ Z14.
+        .setView([39.7292, -104.942], 4);
+        //.setView([39.12367, -76.81229], 9);
+
+    var ATTR_FILTER_CAT = 'data-filtercat';
+
+    var clean = function (s) {
+        return s.toLowerCase().replace(/\s+/g, '');
+    };
+
+    var filter_by_me = function (e) {
+        $('#filters').find('a').removeClass('active');
+        $(e).addClass('active');
+        var cat = clean($(e).attr(ATTR_FILTER_CAT) || ''); // Meow! =^_^=
+        map.markerLayer.setFilter(function(f) {
+            return cat === '*' || clean(f.properties.row.category) === cat;
+        });
+    };
+
+    // Add custom popups to each using our custom feature properties
+    map.markerLayer.on('layeradd', function(e) {
+        var marker = e.layer,
+            feature = marker.feature,
+            row = feature.properties.row;
+
+        // Create custom popup content
+        var popupContent =  [
+                        '<div class="popup-info">',
+                            '<p class="title"><strong>', row.title, '</strong></p>',
+                            '<p class="category">', row.category, '</p>',
+                            '<p><tt class="addres">',
+                                row.addressline1, "<br />",
+                                row.addressline2 || row.addresssline2,
+                                '</tt></p>',
+                        '</div>'
+                    ].join(' ');
+
+        // http://leafletjs.com/reference.html#popup
+        marker.bindPopup(popupContent, {
+            closeButton: true,
+            minWidth: 320
+        });
+
+        var cat = clean(row.category);
+
+        // No category of note
+        if (!cat || cat.length < 1) {
+            return;
+        }
+        var $b = $('#filters ['+ATTR_FILTER_CAT+'='+cat+']');
+        if ($b.length < 1) {
+            // If the layer button does not exist add it
+            var li = [
+                    "<li><a href='#' ", ATTR_FILTER_CAT, "='", cat,"'>",
+                    row.category,"</a></li>"].join("")
+            $('#filters').append(li)
+        }
+    });
+
+
+    $('#filters').on('click', 'a', function () {
+            filter_by_me(this);
+        });
+    map.markerLayer.setGeoJSON(geoJson);
+
+    $('img.spinner').fadeOut();
+    $('#map_ui').show();
+};
+
+$('document').ready(function () {
+    var GEOCODE_API = 'http://maps.googleapis.com/maps/api/geocode/json';
+    var fetched = 0;
+    var geojson = [];
+
+    var push = function (row) {
+        geojson.push({
+                type: 'Feature',
+                geometry: {
+                    type: 'Point',
+                    coordinates: [row.geolongitude, row.geolatitude]
+                },
+                properties: {
+                    'marker-color': '#CC0033',
+                    title: row.title,
+                    row: row
+                }
+            });
+
+    };
+
+    var fetch = function (i, data) {
+        var row = data[i];
+
+        var next = function () {
+            // Fetch next if there are some left
+            if (i+1 < data.length) {
+                fetch(i+1, data);
+            } else {
+                add_spots(geojson);
+            }
+        };
+
+        if (row.geolatitude) {
+            // Already filled out by google docs, just append right now
+            push(row);
+            next();
+        }
+        // Disabling geocoding for the moment, because of issues with some browsers
+        /*
+        else {
+            // Manually fill out
+            var address = row['addressline1'] + ' ' + (row.addressline2 || row.addresssline2 || '');
+
+            $.get(GEOCODE_API, {
+                        address: address,
+                        sensor: false
+                    }, function (a) {
+                        if (!a.results) {
+                            // sometimes is not pre-parsed, parse now
+                            a = $.parseJSON(a);
+                        }
+
+                        // Add lat / longitude data to row
+                        if (a.results && a.results.length > 0) {
+                            // There were results, cool!
+                            var loc = a.results[0].geometry['location'];
+                            row.geolongitude = loc.lng;
+                            row.geolatitude = loc.lat;
+                            push(row);
+                            //console.info("FOUND!", address, row, a);
+                        } else {
+                            console.error("Could not find lat/lon for ", address, a);
+                        }
+                        next();
+                });
+        }
+        */
+    };
+
+    Tabletop.init( {
+                //key: 'https://docs.google.com/spreadsheet/pub?key=0Aj7WbjRT9mlmdFd4RHY0ZklncnRObnMzMU1xaW5vTXc&output=html',
+                key: window.VARS.spreadsheet,
+                simpleSheet: true,
+                callback: function (data, tabletop) {
+                    //console.log(data);
+                    fetch(0, data);
+                }
+            } )
+
+});
+