<commit_before>var map;
var templates;

/* From http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/ */

function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr) {
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined") {
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        xhr = null;
    }
    return xhr;
}

function initAutocomplete() {
//	function log( message ) {
//		$( "<div>" ).text( message ).prependTo( "#log" );
//		$( "#log" ).scrollTop( 0 );
//	}
	var sql = cartodb.SQL({ user: 'codeforkansascity' });
	$( ".cartodb-searchbox .text" ).autocomplete({
		source: function( request, response ) {
			var s
			sql.execute("SELECT cartodb_id, address, the_geom FROM codeforkansascity.kcmo_parcels_6_18_2015_kiva_nbrhd WHERE address LIKE '" + request.term + "%' ORDER BY address")
			.done(function(data) {
				response(data.rows.map(function(r) {
            		//console.log(r);
					return {
						label: r.address,
						value: r.address
					}
				}))
			})
		},
		minLength: 2,
		select: function( event, ui ) {
			console.log("Selected: " + ui.item.value);
			//var bounds = new google.maps.LatLngBounds();
			//for(i=0;i<r.length;i++) {
			//	bounds.extend(r[i].getPosition());
			//}
			//map.fitBounds(bounds);
			// "Nothing selected, input was " + this.value );
		}
	});

};
//console.log("SELECT cartodb_id, address FROM codeforkansascity.kcmo_parcels_6_18_2015_kiva_nbrhd WHERE address LIKE '" + request.term + "%' ORDER BY address");


function main() {
/**
    var options = {
        center: [39.082981, -94.557747],
        zoom: 16,
        zoomControl: false,  // dont add the zoom overlay (it is added by default)
        loaderControl: false, //dont show tiles loader
        query: 'SELECT * FROM data'

    };

    map = new L.Map('map', options);

    L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
        attribution: 'Positron'
    }).addTo(map);

    new L.Control.Zoom({position: 'topleft'}).addTo(map);
**/

   var map;

    // create google maps map
    var mapOptions = {
      zoom: 10,
      center: new google.maps.LatLng(39.09, -94.53),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map'),  mapOptions);

    var datalayer = 'https://code4kc.cartodb.com/api/v2/viz/8167c2b8-0cf3-11e5-8080-0e9d821ea90d/viz.json';
    var geomlayer = 'https://codeforamerica.cartodb.com/u/codeforkansascity/api/v2/viz/4e032b12-1dfe-11e5-8ca7-0e49835281d6/viz.json'

    cartodb.createLayer(map, geomlayer).addTo(map, 0).on('done', function(layer){
		var v = cdb.vis.Overlay.create('search', map.viz, {})
		v.show();
		$('#map').append(v.render().el);
		initAutocomplete();
    })
    .on('error', function(){
    	cartodb.log.log("Error");
    });

    cartodb.createLayer(map, datalayer).addTo(map, 1).on('done', function (layer) {
        var sublayer = layer.getSubLayer(2); //sublayer generated from the data.json file
        sublayer.infowindow.set('template', $('#infowindow_template').html());
        sublayer.setInteraction(true);
        //add more data as needed:
        sublayer.setInteractivity('cartodb_id, address, apn, kivapin, land_ban30, land_ban_6, land_ban_4, land_ban_6, land_ban_7, land_ban10, land_ban36, land_ban56, land_ban60, land_bank_, own_name, landusecod, land_ban32, land_ban_3');
        sublayer.on('featureClick', function (e, latlng, pos, data, layer) {

            var request_jd_wp = createCORSRequest("get", "http://address-api.codeforkc.org/jd_wp/" + data.apn);
            var api_data = null;
            if (request_jd_wp) {<commit_msg>switched initial zoom and center coordinates<commit_after>var map;
var templates;

/* From http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/ */

function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr) {
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined") {
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        xhr = null;
    }
    return xhr;
}

function initAutocomplete() {
//	function log( message ) {
//		$( "<div>" ).text( message ).prependTo( "#log" );
//		$( "#log" ).scrollTop( 0 );
//	}
	var sql = cartodb.SQL({ user: 'codeforkansascity' });
	$( ".cartodb-searchbox .text" ).autocomplete({
		source: function( request, response ) {
			var s
			sql.execute("SELECT cartodb_id, address, the_geom FROM codeforkansascity.kcmo_parcels_6_18_2015_kiva_nbrhd WHERE address LIKE '" + request.term + "%' ORDER BY address")
			.done(function(data) {
				response(data.rows.map(function(r) {
            		//console.log(r);
					return {
						label: r.address,
						value: r.address
					}
				}))
			})
		},
		minLength: 2,
		select: function( event, ui ) {
			console.log("Selected: " + ui.item.value);
			//var bounds = new google.maps.LatLngBounds();
			//for(i=0;i<r.length;i++) {
			//	bounds.extend(r[i].getPosition());
			//}
			//map.fitBounds(bounds);
			// "Nothing selected, input was " + this.value );
		}
	});

};
//console.log("SELECT cartodb_id, address FROM codeforkansascity.kcmo_parcels_6_18_2015_kiva_nbrhd WHERE address LIKE '" + request.term + "%' ORDER BY address");


function main() {
/**
    var options = {
        center: [39.082981, -94.557747],
        zoom: 16,
        zoomControl: false,  // dont add the zoom overlay (it is added by default)
        loaderControl: false, //dont show tiles loader
        query: 'SELECT * FROM data'

    };

    map = new L.Map('map', options);

    L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
        attribution: 'Positron'
    }).addTo(map);

    new L.Control.Zoom({position: 'topleft'}).addTo(map);
**/

   var map;

    // create google maps map
    var mapOptions = {
      zoom: 15,
      center: new google.maps.LatLng(39.082981, -94.557747),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map'),  mapOptions);

    var datalayer = 'https://code4kc.cartodb.com/api/v2/viz/8167c2b8-0cf3-11e5-8080-0e9d821ea90d/viz.json';
    var geomlayer = 'https://codeforamerica.cartodb.com/u/codeforkansascity/api/v2/viz/4e032b12-1dfe-11e5-8ca7-0e49835281d6/viz.json'

    cartodb.createLayer(map, geomlayer).addTo(map, 0).on('done', function(layer){
		var v = cdb.vis.Overlay.create('search', map.viz, {})
		v.show();
		$('#map').append(v.render().el);
		initAutocomplete();
    })
    .on('error', function(){
    	cartodb.log.log("Error");
    });

    cartodb.createLayer(map, datalayer).addTo(map, 1).on('done', function (layer) {
        var sublayer = layer.getSubLayer(2); //sublayer generated from the data.json file
        sublayer.infowindow.set('template', $('#infowindow_template').html());
        sublayer.setInteraction(true);
        //add more data as needed:
        sublayer.setInteractivity('cartodb_id, address, apn, kivapin, land_ban30, land_ban_6, land_ban_4, land_ban_6, land_ban_7, land_ban10, land_ban36, land_ban56, land_ban60, land_bank_, own_name, landusecod, land_ban32, land_ban_3');
        sublayer.on('featureClick', function (e, latlng, pos, data, layer) {

            var request_jd_wp = createCORSRequest("get", "http://address-api.codeforkc.org/jd_wp/" + data.apn);
            var api_data = null;
            if (request_jd_wp) {
{'fraction_non_alphanumeric': 0.1636051275274217, 'fraction_numerical': 0.03277388661292454, 'mean_word_length': 3.0908108108108108, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6902650', 'n_tokens_mistral': 2991, 'n_tokens_neox': 2720, 'n_words': 513}