var map; var locmgr; var baseicon = new GIcon(); baseicon.image = "/images/mapicons/mm_20_red.png"; baseicon.shadow = "/images/mapicons/mm_20_shadow.png"; baseicon.iconSize = new GSize(12, 20); baseicon.shadowSize = new GSize(22, 20); baseicon.iconAnchor = new GPoint(6, 20); baseicon.infoWindowAnchor = new GPoint(5, 1); var stateicon = new GIcon(baseicon); stateicon.image = "/images/mapicons/icon491.png"; stateicon.shadow = "/images/mapicons/icon49s1.png"; stateicon.iconSize=new GSize(16,16); stateicon.shadowSize=new GSize(28,16); stateicon.iconAnchor=new GPoint(7,11); stateicon.infoWindowAnchor=new GPoint(8,8); var locicon = new GIcon(baseicon); locicon.image = "/images/mapicons/mm_20_green.png"; var criteria = ''; function start(){ var temp; } //Loads the list of locations and links to state summaries into the sidebar //Requires state, should also utilize species and user to limit results function get_popular_states(state){ document.getElementById("subcontent").innerHTML=''; var temp; //temp = 'state=' + state + '&' + criteria.substring(1,criteria.length); temp = criteria; $.ajax({ //url: "/get_popular_states.php", url:"/get_xml/get_StateLocList/"+state+"/"+criteria, //data: temp, success: function(msg){ document.getElementById("subcontent").innerHTML=msg; //TB_init(); } }); } // returns the list of state centers in xml format //used to put markers on map and create list of state links // can use species or user to limit results /* function get_state_centers(criteria){ $.ajax({ url: "/getstatecenters.php", data: criteria, success: function(msg){ document.getElementById("content").innerHTML=msg; } }); } */ //returns list of current sightings and summary information for a locations //why are we passing description instead of the location ID, could theoretcially have the //same description for multiple locations?? //Pass both/ or have the php file grab the description //where else is this calleD? function get_location_sightings(locID,description){ document.getElementById("subcontent").innerHTML=''; var temp; /* if(species >0){ temp = 'state='+state+'&Description='+description+'&species_id='+species; }else{ temp = 'state='+state+'&Description='+description; } */ temp = 'RBALocationsID=' + locID + '&Description='+description + "&" + criteria.substring(1,criteria.length);; $.ajax({ url: "/get_xml/get_LocSightings/"+locID+"/"+criteria, //data: temp, success: function(msg){ document.getElementById("subcontent").innerHTML=msg; //alert("test1"); //tb_init(); //alert("test"); tb_init('a.thickbox, area.thickbox, input.thickbox'); } }); } function updateZoomsState(){ var temp; temp = 'Return to default view '; document.getElementById("zooms").innerHTML=temp; } function updateZoomsLocation(Lat,Lon,Prec){ var temp; temp = 'Return to default view / '; temp += 'Return to State View'; document.getElementById("zooms").innerHTML=temp; } function zoomState(Lat,Lon,Prec,state,statename){ zoomPoint(Lat,Lon,Prec); get_popular_states(statename); getstatelocs(statename); //updateZoomsState(Lat,Lon,Prec) } function zoomLocation(Lat,Lon,Prec,state,description){ zoomPoint(Lat,Lon,Prec); get_location_sightings(state); //updateZoomsLocation(Lat,Lon,Prec) } function zoomPoint(Lat,Lon,Prec){ map.closeInfoWindow(); newpoint = new GLatLng(parseFloat(Lat),parseFloat(Lon)); map.setCenter(newpoint,Prec); map.setZoom(Prec); } function createStateMarker(point,theid,title,x,y,prec) { var marker = new GMarker(point,{title:title, icon:stateicon}); var html = '
' + title + ' (Zoom)
Popular Locations
'; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } function createLocMarker(point,theid,title,x,y) { var marker = new GMarker(point,{title:title, icon:locicon}); var showtitle = title.replace(/'/g, "\\'"); //alert(showtitle); var html = '
' + title + ' (Zoom)
Recent Sightings
'; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } function statebox(y,x,title,prec){ var retval; retval = '
  • ' + title + '
  • '; //alert(retval); return retval; } function linkbox(y,x,title,prec,state){ var retval; retval = '' + title + ' '; //alert(retval); return retval; } function load() { //alert(criteria); //get_state_centers(); if (GBrowserIsCompatible()) { var om = new OverlayMessage(document.getElementById('map')); om.Set('Loading...'); map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GOverviewMapControl()); map.setCenter(new GLatLng(42, -95), 3); var mgr = new GMarkerManager(map); locmgr = new GMarkerManager(map); var call = "/get_xml/get_StateCenters/" + criteria; //var call = "/getstatecenters.php" + criteria; //Need to update this to use criteria (serialize?) ; GDownloadUrl(call, function(data) { var temp = '

    States/Provinces with Sightings:

    USA

    '; var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); if(markers[i].getAttribute("ab") == 'AB'){ temp += '

    Canada

    '}; if(markers[i].getAttribute("type") == 'used'){ marker = createStateMarker(point,markers[i].getAttribute("id"), markers[i].getAttribute("title"),markers[i].getAttribute("vlng"),markers[i].getAttribute("vlat"),markers[i].getAttribute("prec")); temp += linkbox(markers[i].getAttribute("vlat"),markers[i].getAttribute("vlng"),markers[i].getAttribute("ab"),markers[i].getAttribute("prec"),markers[i].getAttribute("title")); mgr.addMarker(marker, 0, 4); } else{ temp += ' ' + markers[i].getAttribute("ab") + ' '; } //alert(temp); } temp += ''; if(i == 0){ temp += 'No Sightings were found'; } //var link = xml.documentElement.getElementsByTagName("link"); //alert(markers[0]); temp +='
    '; document.getElementById("links").innerHTML=temp; //temp += statebox(markers[i].getAttribute("lat"),markers[i].getAttribute("lng"),markers[i].getAttribute("title")); //document.getElementById("subcontent").innerHTML=temp; om.Clear(); // Clear the loading message }); start(); } } function getstatelocs(state){ map.clearOverlays(); //var call = "/getlocs.php?" + 'state=' + state + '&' + criteria.substring(1,criteria.length); var call = "/get_xml/get_StateLocs/" + state + "/" + criteria; //alert('test'); GDownloadUrl(call, function(data) { var xml = GXml.parse(data); //alert(xml); var markers = xml.documentElement.getElementsByTagName("marker"); //alert(markers.length); for (var i = 0; i < markers.length; i++) { //alert(i); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); marker = createLocMarker(point,markers[i].getAttribute("id"), markers[i].getAttribute("title"),markers[i].getAttribute("lng"),markers[i].getAttribute("lat"),markers[i].getAttribute("state")); map.addOverlay(marker); //locmgr.addMarker(marker, 5, 17); } }); }