/
app_mobile.js
10 lines (10 loc) · 4.39 KB
/
app_mobile.js
1
2
3
4
5
6
7
8
9
10
var map,ie_cartodb1_gmapsv3,ie_cartodb2_gmapsv3;function toggleFullscreen(){}
function initialize(){var h={zoom:9,center:new google.maps.LatLng(29.05,-81.25),mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,styles:[{stylers:[{saturation:-75}]},{featureType:"administrative",stylers:[{visibility:"off"}]},{featureType:"road.highway",stylers:[{gamma:6.18},{hue:"#3c00ff"},{lightness:74},{saturation:54},{visibility:"simplified"}]},{featureType:"road.arterial",stylers:[{visibility:"simplified"},{saturation:90},{lightness:54}]},{featureType:"water",stylers:[{saturation:18}]},
{elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi.park",stylers:[{visibility:"simplified"},{lightness:30},{saturation:-7}]},{elementType:"labels",stylers:[{visibility:"off"}]}]};map=new google.maps.Map(document.getElementById("map_canvas"),h);google.maps.event.addDomListener(document.getElementById("zoom_in"),"click",function(){map.setZoom(map.getZoom()+1)});google.maps.event.addDomListener(document.getElementById("zoom_out"),"click",function(){map.setZoom(map.getZoom()-1)});if($.browser.msie){var h=
document.getElementsByTagName("head")[0],f=document.createElement("script");f.id="uploadScript";f.type="text/javascript";f.src="cartodb-gmapsv3.js?x="+Math.random();h.appendChild(f);f.onreadystatechange=function(){ie_cartodb2_gmapsv3=new google.maps.CartoDBLayer({map_canvas:"map_canvas",map:map,user_name:"wsj",table_name:"volusiaboundary",query:"SELECT * FROM volusiaboundary",map_style:!0,infowindow:!1,auto_bound:!1});ie_cartodb1_gmapsv3=new google.maps.CartoDBLayer({map_canvas:"map_canvas",map:map,
user_name:"wsj",table_name:"volusia_homes_data",map_style:!0,query:"SELECT * FROM volusia_homes_data WHERE cartodb_id != -1",infowindow:!0,auto_bound:!1})}}else{var i=new CartoDB({user:"wsj",table:"volusia_homes_data",columns:["cartodb_id","zipcode","percent_delinquent"],where:"percent_delinquent IS NOT NULL",debug:!1,shader:{"point-color":"#FFF","line-color":"rgba(0, 0, 0, 0.4)","line-width":function(b){return-1==b.cartodb_id?3:0.7},"polygon-fill":function(b){if(-1==b.cartodb_id)return"rgba(0,0,0,0)";
var b=b.percent_delinquent,a=0;0.22>=b&&(a++,0.195>b&&(a++,0.17>b&&(a++,0.145>b&&(a++,0.12>b&&(a++,0.95>b&&a++)))));return"rgba(252, 187, 161,0.7);rgba(252, 146, 114,0.7);rgba(251, 106, 74,0.7);rgba(239, 59, 44,0.7);rgba(203, 24, 29,0.7);rgba(165, 15, 21,0.7);rgba(103, 0, 13,0.7)".split(";")[a]}}});map.overlayMapTypes.insertAt(0,i.layer);var j=new MercatorProjection,d=[],g=new CartoDBInfowindow(map);google.maps.event.addListener(map,"click",function(b){var a=j.latLngToTile(b.latLng,map.zoom),a=i.layer.tiles[a.x+
"_"+a.y+"_"+map.zoom],c=1<<map.zoom,c=new google.maps.Point(Math.floor(b.point.x*c%256),Math.floor(b.point.y*c%256)),c=a.hit_ctx.getImageData(c.x,c.y,1,1).data;if(0!==c[3]){var e=RGB2Int(c[0],c[1],c[2]);if(a.primitives&&a.primitives[e]&&-1!=a.primitives[e].properties.cartodb_id)JSON.stringify(a.primitives[e].geometry),opts={strokeColor:"#FFF366",strokeOpacity:0.8,strokeWeight:2,fillColor:"#FFF366",fillOpacity:0.6},0<d.length&&(d.forEach(function(a){a.setMap(null);google.maps.event.clearListeners(a,
"click")}),d.remove(0,d.length-1)),c=new GeoJSON(a.primitives[e].geometry,opts),!c.error&&void 0===c.length&&(c.setMap(map),d.push(c)),c=(100*a.primitives[e].properties.percent_delinquent).toFixed(1),a=a.primitives[e].properties.zipcode,Math.pow(2,map.getZoom()),e=new google.maps.LatLng(map.getBounds().getNorthEast().lat(),map.getBounds().getSouthWest().lng()),map.getProjection().fromLatLngToPoint(e),map.getProjection().fromLatLngToPoint(b.latLng),g.draw(b.latLng,'<a href="#close" class="close">x</a><div class="outer_top"><div class="top"><p>Homes seriously delinquent or in foreclosure</p></div></div><div class="bottom"><label class="strong">'+
c+'% </label><label class="box">ZIP CODE: '+a+" </label></div>"),g.start()}else 0<d.length&&(d.forEach(function(a){a.setMap(null);google.maps.event.clearListeners(a,"click")}),d.remove(0,d.length-1))});Array.prototype.remove=function(b,a){var c=this.slice((a||b)+1||this.length);this.length=0>b?this.length+b:b;return this.push.apply(this,c)}}$("#fullscreen").click(function(){map.getBounds();var b=map.getCenter(),a=map.getZoom();$("body").hasClass("fullscreen")?($("body").removeClass("fullscreen"),
a--):($("body").addClass("fullscreen"),a++);g&&g.hideAll();google.maps.event.trigger(map,"resize");map.setCenter(b);map.setZoom(a)})}google.maps.event.addDomListener(window,"load",initialize);