﻿
var cityData = [];
var cityPoints = [];

var MapState = function(CenterLatLon, ZoomLevel, MapStyle) {
		this.CenterLatLon = CenterLatLon;
		this.ZoomLevel = ZoomLevel;
		this.MapStyle = MapStyle;
	}

MapState.toJSON = function() {
	return ("CenterLatLon=" + CenterLatLon.toString() + "&ZoomLevel=" + ZoomLevel.toString() + "&MapStyle=" + MapStyle.toString()).toJSON();
}


function initializeCityData() {
	$.get("AjaxDataPages/MapDataService.aspx?wID=" + CurrentAgent.WebID + "&RequestType=CityMarkers.DataTable", cityDataLoaded, 'text');
}

function AjaxError(err) {
	alert('Error: ' + err.status + '\nStatusText: ' + err.statusText);
}

function cityDataLoaded(response) {

	/* eval() the response to load the data into cityData */
	eval(response.responseText);

	// Note: Start incrementor at 1!!!! ****
	for (var i = 1; i < cityData.length; i++) {
		cityPoints.push(new VELatLong(cityData[i][2], cityData[i][3]));
		polygonAddPushpin(new VELatLong(cityData[i][2], cityData[i][3]), "", { title: trimChar(cityData[i][0], ","), icon: "<img src=\"images/StarWithBorder.png\" border=\"0\" onmouseup=\"alert('Load " + trimChar(cityData[i][0], ",") + "')\" />", description: "Property Count: " + formatNumber(cityData[i][1], 0) + "<br />Avg Price: $" + formatNumber(cityData[i][4], 0) + "<br />Min Price: $" + formatNumber(cityData[i][5], 0) + "<br />Max Price: $" + formatNumber(cityData[i][6], 0) + "<br />80% Avg Price: $" + formatNumber(cityData[i][8], 0) });
	}
	map.SetMapView(cityPoints);
}




