var plan_key = ''; var meet_loc_url = '/unc/meet-location'; // handy images var img_zipmarker, img_youarehere, img_nomatch, img_expanded, img_unknown; img_youarehere = "/images/zipmarker-youarehere.png"; img_nomatch = "/images/zipmarker-reserved.png"; img_expanded = "/images/zipmarker-viewing.png"; img_zipmarker = "/images/zipmarker.png"; img_unknown = "/images/zipmarker-unknown.png"; img_shadow = "/images/zipshadow.png"; // create a data structure for all the locations var locs = [ [7809804,'Beard+Lot',35.906998485557,-79.05354002045729],[3853414,'Bynum+Hall+-+North+Campus',35.9117819105,-79.0505889916],[88875536,'Medical+Drive',35.907162148019154,-79.05184507369995],[3853400,'Swain+Hall+-+North+Campus',35.9117584105,-79.0531089916],[3853450,'UNC+Department+of+Public+Safety',35.9033292124,-79.0480200487],[7239389,'Wilson+Library+Lot',35.908937064184535,-79.05001848936081]]; // create a data structure for all the location groups var loc_grps = [ [3998280, 35.90832787186011483333333333333333333333, -79.05118693590300833333333333333333333333, 15]]; // even though we have vehicle_id, it is not relevant at this stage since it will just be used for // counting up how many vehicles match said criteria. we will leave it out of the array. // make, model, location, amenity list var vehicles = [ [94564,742432,7239389,['']],[94564,742432,7809804,[49167247,'']],[4264850,4264865,3853400,[49167247,'']],[94564,3398752,3853450,[49167247,'']],[94564,742432,3853414,[49167247,'']],[94563,163026706,88875536,[49167247,'']] ]; // local array of makes and models so we can tell which is which var mks_mos = [[94563,1],[163026706,0],[4264850,1],[4264865,0],[94564,1],[742432,0],[3398752,0]]; // get a local set of ids for the amenities (we dont really need the description, unless // we want to get really fancy and have the form adjust itself based on selections made // (only show relevant body styles / amenities / neighborhoods based on the chosen make/model) var amenities = [49167247]; // get a local set of ids for the styles so we can easily figure out what styles are needed var styles = [142802904,8586495,8577473]; // get a local mapping of locations to location groups. this allows us to trim accordion // results by neighborhood. var lgmap = [[3853400,3998280],[3853414,3998280],[3853450,3998280],[7239389,3998280],[7809804,3998280],[88875536,3998280]]; // get a local mapping of models to styles. this allows us to trim accordion results by style var stylemap = [[742432,8577473],[3398752,8586495],[4264865,8577473],[163026706,8586495],[163026706,142802904]]; // globals for finding your local address in the search box var closestaddr = new Object(); var firstaddr = new Object(); var addrstr; // TODO: right now, this just returns the coords for one address, // we should expand this to support multiple address geocoding function refreshCarsByAddress() { var addr = document.getElementById('gmaps-address').value; addrstr = addr; var new_addr; if (addr.match(/[ ]*/) != null && addr != "enter some or all of an address") { geocode(addrstr, function (p) { // see if this address is closer to the current fleet of a modified address is closer if (p) { firstaddr.lat = p.lat(); firstaddr.lng = p.lng(); } else { // this is kinda lame, but at least it is in the ocean firstaddr.lat = 0; firstaddr.lng = 0; } geocode(addrstr + ', North Carolina', function (s) { var old_dist, new_dist, e; if (!s && (firstaddr.lat == 0 && firstaddr.lng == 0)) { closestaddr.lat = 0; closestaddr.lng = 0; } else if (!s) { closestaddr.lat = firstaddr.lat; closestaddr.lng = firstaddr.lng; } else if (firstaddr.lat == 0 && firstaddr.lng == 0) { closestaddr.lat = s.lat(); closestaddr.lng = s.lng(); } else { old_dist = Math.sqrt(Math.pow(firstaddr.lat - 35.90832787, 2) + Math.pow(firstaddr.lng - -79.05118694, 2)); new_dist = Math.sqrt(Math.pow(s.lat() - 35.90832787, 2) + Math.pow(s.lng() - -79.05118694, 2)); if (old_dist >= new_dist) { closestaddr.lat = s.lat(); closestaddr.lng = s.lng(); } else { closestaddr.lat = firstaddr.lat; closestaddr.lng = firstaddr.lng; } } if (!(closestaddr.lat == 0 && closestaddr.lng == 0)) { find_loc.in_progress = 1; find_loc.retry = 1; place_home(closestaddr.lat, closestaddr.lng); recenter(eval(find_loc.map), closestaddr.lat, closestaddr.lng, 16, 0); e = document.getElementById('location_group_id'); if (e) { e.selectedIndex = 0; } $('#new-type-filter').hide(); find_loc.in_progress = 0; refreshAccordion(find_loc); } else { alert("sorry, we couldn't find that address"); } }); }); } }