my google map codes (keep updating)

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Residential.aspx.cs" Inherits="Residential" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  
<title>Residential Iframe</title>
   
<link href="RESULTS.css" rel="stylesheet" type="text/css" />
   
<script type="text/javascript">
<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function formatCurrency(num) {
num 
= num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num 
= "0";
sign 
= (num == (num = Math.abs(num)));
num 
= Math.floor(num*100+0.50000000001);
cents 
= num%100;
num 
= Math.floor(num/100).toString();
if(cents<10)
cents 
= "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length
-(4*i+3));
//return (((sign)?'':'-') + '$' + num + '.' + cents);
return (((sign)?'':'-'+ '$' + num);
}

//  End -->
</script>
  
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA0fjp2tHrrQJwoaRp8r_sYxR9fR65Vek3QPwU0sVxyfrqv-3SrxSOi2QPW6Z4SZY2sm8l2ZDVezrplA" type="text/javascript"></script>   
  
<script type="text/javascript">    
var addressCheckedCount;
var goodAddressList;
var totalList;
var goodLongitudeList;
var goodLatitudeList;
var map;
var geocoder;
var request=false;
var minPrice = 0;
var maxPrice = 6000000;
var priceRange = 2000000;
var bedroom = 1;
var bedroomRange = 8;
var bathroom = 1;
var bathroomRange = 8;
var type = "";
var parking= "";
var leftPointerDoDrag = false;
var rightPointerDoDrag = false;
var singlePointerDoDrag = false;
var currentLeftPointer;
var currentRightPointer;
var currentSinglePointer;
var currentBar;
var leftPointerMouseOffset;
var rightPointerMouseOffset;
var singlePointerMouseOffset;
var gdir;
var baseIcon = new GIcon();
baseIcon.shadow 
= "http://www.thesarasotamls.com/mapfiles/orange_marker.png";
baseIcon.iconSize 
= new GSize(2023);
baseIcon.shadowSize 
= new GSize(2023);
baseIcon.iconAnchor 
= new GPoint(2023);
baseIcon.infoWindowAnchor 
= new GPoint(92);
baseIcon.infoShadowAnchor 
= new GPoint(1825);
var tooltip = document.createElement("div");
tooltip.setAttribute(
"id","marker_tooltip");
tooltip.style.border
="1px #2E68AF solid";
tooltip.style.backgroundColor
="#ffffff";
tooltip.style.fontWeight
="bold";
tooltip.style.overflow
="hidden";

try
{
 request 
= new XMLHttpRequest();//Firefox
}

catch(trymicrosoft)
{
 
try 
 
{
    request 
= new ActiveXObject("Msxml2.XMLHTTP.5.0");//New IE
 }
 
 
catch(othermicrosoft)
 
{
    
try 
    
{
          request 
= new ActiveXObject("Microsoft.XMLHTTP");//Old IE
    }
 
    
catch(failed)
    
{
          request 
= false;//Unknown browser
    }

 }

}


function buildList(content)
{
  totalList 
= content.split("-");
  addressCheckedCount 
= 0;
  makeCorrectList(totalList);
}

function makeCorrectList(totalList)
{
   map.clearOverlays();
   goodAddressList 
= new Array();
   goodLongitudeList 
= new Array();
   goodLatitudeList 
= new Array();
   
for(i=0;i<totalList.length;i++)
   
{
      checkAndAddPoint(totalList[i]);
   }

}

function checkAndAddPoint(address)
{
   
if(geocoder)
   
{
      geocoder.getLatLng
      (
        address,
        
function(point)
        
{
          
if(point)
          
{
            setGoogleMapLocations(address);
            goodAddressList[goodAddressList.length] 
= address;
            goodLongitudeList[goodLongitudeList.length] 
= point.lng();
            goodLatitudeList[goodLatitudeList.length] 
= point.lat();
          }

          addressCheckedCount
++;
          
if(addressCheckedCount >= totalList.length)
          
{
                setRelativeCenterPoint();
          }

        }

      );
   }

}

function setRelativeCenterPoint()
{
  
var relativeLongitudePlusLatitude = 10000000000;
  
var averageLongitude = getAverageLongitude();
  
var averageLatitude = getAverageLatitude();
  
var location;
  
for(var i=0;i<goodAddressList.length;i++)
  
{
    
if((Math.abs(goodLatitudeList[i]-averageLatitude)+Math.abs(goodLongitudeList[i]-averageLongitude))<relativeLongitudePlusLatitude)
    
{
        relativeLongitudePlusLatitude 
= Math.abs(goodLatitudeList[i]-averageLatitude)+Math.abs(goodLongitudeList[i]-averageLongitude);
        location 
= i;
    }

  }

  setGoogleMapCommunity(goodAddressList[location]);
}
  
function getAverageLatitude()
{
  
var total=0;
  
for(var i =0;i<goodLatitudeList.length;i++)
  
{
    total 
= total + goodLatitudeList[i];
  }

  
return total/goodLatitudeList.length;
}

function getAverageLongitude()
{
  
var total=0;
  
for(var i=0;i<goodLongitudeList.length;i++)
  
{
    total 
= total + goodLongitudeList[i];
  }

  
return total/goodLongitudeList.length;
}

function initialize() 
{      
 
if (GBrowserIsCompatible()) 
 
{
      map 
= new GMap2(document.getElementById("map_canvas"));
      geocoder 
= new GClientGeocoder();
      map.addControl(
new GSmallMapControl());
      map.addControl(
new GMapTypeControl());
      
var center = new GLatLng('51.053728''-114.062474')
      map.setCenter(center, 
6);
      gdir 
= new GDirections(map);
      GEvent.addListener(gdir, 
"load", onGDirectionsLoad);
      GEvent.addListener(gdir, 
"error", handleErrors);
      map.getContainer().appendChild(tooltip); 
  }

}

function setDirections(fromAddress, toAddress, locale) 
{
    gdir.load(
'from: '+fromAddress+' to: '+toAddress);
}

function onGDirectionsLoad() 
{
    alert(gdir.getStatus().code);
    document.getElementById(
"getDistance").innerHTML = gdir.getSummaryHtml();
}

function handleErrors()
{
    
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
    
{
        alert(
"No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
    
{
        alert(
"A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
    
{
        alert(
"The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
    
{
        alert(
"The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    
{
        alert(
"A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
    }

    
else
    

        alert(
"An unknown error occurred.");
    }

}

function sendRequest(queryString)
{
   isCommunityAlreadySet 
= false;
   url
=escape("search.aspx")+"?random=" + Math.random();//use a random number to avoid cache
   request.open("Post",url,true);//connection method
   request.onreadystatechange=showProcess;//show Process method
   request.setRequestHeader('Content-Type''application/x-www-form-urlencoded; charset=utf-8');
   request.send(
"Search="+escape(queryString));
}

function showProcess() 
{
   
if(request.readyState == 4)//finished
   {
      
if(request.status == 200)//normal
      {
         eval(request.responseText);
//insert script to add locations to google map
      }

   }

}

function setGoogleMapCity(latitude, longtitude)
{
 
if (GBrowserIsCompatible()) 
 
{
      map.clearOverlays();
      map.setCenter(
new GLatLng(latitude, longtitude), 10);
 }

}

function setGoogleMapCityDistrict(latitude, longtitude)
{
 
if (GBrowserIsCompatible()) 
 
{
    
var center = new GLatLng(latitude, longtitude)
    map.setCenter(center, 
11);
    
var marker = new GMarker(center, {draggable: true});
    GEvent.addListener
    (
        marker, 
        
"dragstart"
        
function()
        
{
            map.closeInfoWindow();
        }

    );
    GEvent.addListener
    (
        marker, 
        
"dragend"
        
function() 
        
{
            marker.openInfoWindowHtml(
"The surrounding search results<br> are for houses within a 10 <br> block radius of this pointer.");
        }

    );
    map.clearOverlays();
    map.addOverlay(marker);
 }

}

function setGoogleMapTown(address)
{
   
if(geocoder)
   
{
      geocoder.getLatLng
      (
        address,
        
function(point)
        
{
          
if(point)
          
{
            map.setCenter(point, 
11);
          }

        }

      );
   }

   map.clearOverlays();
}

function setGoogleMapCommunity(address)

    
   
if(geocoder)
   
{
      geocoder.getLatLng
      (
        address,
        
function(point)
        
{
          
if(point)
          
{
            map.setCenter(point, 
12);
          }

        }

      );
   }

}

function setGoogleMapLocations(address, picture, link, price)
{
   
if(geocoder)
   
{
      geocoder.getLatLng
      (
        address,
        
function(point)
        
{
          
var marker;
          
if(point)
          
{
            
var icon = new GIcon(baseIcon);
            marker 
= new GMarker(point,icon);
            marker.tooltip 
= "<div style='width: 192px;height: auto;test-align: center; padding: 5px;'><h5 style='background-color:#3157A3;color:#fff;font-size:11px;padding: 5px;margin:0 0 5px 0'>Click For More Information</h5><img width='190' height='115' style='border:1px solid #666' src='http://pic.rewhosting.com/sar/images/369792_101.jpg' onError='swapimage(this);'><p style='margin-bottom:0'>$709,000</p></div>";
            map.addOverlay(marker);
            GEvent.addListener
            (
              marker, 
              
"click"
              
function() 
              
{
                  
var content = "";
                  content 
= "what do we need to show?";
//                      content = content + "<img src=\"";
//
                      content = content + picture;
//
                      content = content + "\"/><b><a href=\"";
//
                      content = content + link;
//
                      content = content + "\" target=\"_blank\">MLS # C3293828</a></b>";
//
                      content = content + "<br /><b>Listing Price: </b>";
//
                      content = content + price;
//
                      content = content + "<br />";
                  marker.openInfoWindowHtml(content);
                  
              }

            );
            GEvent.addListener
            (
                marker,
                
"mouseover"
                
function() 
                
{
                    tooltip.innerHTML 
= marker.tooltip;
                    
var gPoint=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
                    
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
                    
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - gPoint.x + 11,- offset.y + gPoint.y +2)); 
                    pos.apply(tooltip);
                    tooltip.style.visibility
="visible";
                }

            ); 
          }

        }

      );
   }

}

function selectCityOrTown()
{
    communityObject 
= document.getElementById("dd_Community");
    communityName 
= communityObject.options[communityObject.selectedIndex].value;
    cityOrTownObject 
= document.getElementById("dd_CityOrTown");
    cityOrTownName 
= cityOrTownObject.options[cityOrTownObject.selectedIndex].value;
    districtObject 
= document.getElementById("dd_District");
    districtName 
= districtObject.options[districtObject.selectedIndex].value;
    
if(cityOrTownName != "")
    
{
        
if(cityOrTownName == "Calgary")
        
{
            document.getElementById(
"lb_District").style.display = "inline";
            document.getElementById(
"dd_District").style.display = "inline";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            setGoogleMapCity(
51.053728,-114.062474);
            map.clearOverlays();
        }

        
else if(cityOrTownName == "Edmonton")
        
{
            document.getElementById(
"lb_District").style.display = "inline";
            document.getElementById(
"dd_District").style.display = "inline";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            setGoogleMapCity(
53.540969,-113.493704);
            map.clearOverlays();
        }

        
else//town
        {
            document.getElementById(
"lb_District").style.display = "none";
            document.getElementById(
"dd_District").style.display = "none";
            document.getElementById(
"lb_Community").style.display = "none";
            document.getElementById(
"dd_Community").style.display = "none";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            
if(isOKToSendRequest())
            
{
                sendRequest(buildQueryString());
            }

        }

    }

}

function selectDistrict()
{
    selectList 
= document.getElementById("dd_District");
    selectedValue 
= selectList.options[selectList.selectedIndex].value;
    
if(selectedValue != "")
    
{
        document.getElementById(
"lb_Community").style.display = "inline";
        document.getElementById(
"dd_Community").style.display = "inline";
        document.getElementById(
"dd_Community").options.length = 0;
        document.getElementById(
"dd_Community").options[0= new Option(""""falsefalse);
        cityObject 
= document.getElementById("dd_CityOrTown");
        cityName 
= cityObject.options[cityObject.selectedIndex].value;
        
if(cityName == "Calgary")
        
{
            
if(selectedValue == "NW")
            
{
                setGoogleMapCityDistrict(
51.104384244689136,-114.19532775878906);
            }

            
else if(selectedValue == "NE")
            
{
                setGoogleMapCityDistrict(
51.114299564839285,-113.91448974609375);
            }

            
else if(selectedValue == "SE")
            
{
                setGoogleMapCityDistrict(
50.98091164990174,-113.89320373535156);
            }

            
else if(selectedValue == "SW")
            
{
                setGoogleMapCityDistrict(
50.981343945663895,-114.19258117675781);
            }

        }

        
else if(cityName == "Edmonton")
        
{
            
if(selectedValue == "NW")
            
{
                setGoogleMapCityDistrict(
53.6132842735673,-113.66798400878906);
            }

            
else if(selectedValue == "NE")
            
{
                setGoogleMapCityDistrict(
53.60839590747473,-113.33152770996094);
            }

            
else if(selectedValue == "SE")
            
{
                setGoogleMapCityDistrict(
53.47905653761052,-113.33908081054688);
            }

            
else if(selectedValue == "SW")
            
{
                setGoogleMapCityDistrict(
53.472926582928956,-113.66729736328125);
            }

        }

        sendRequest(buildQueryString());
    }

    
else
    
{
        document.getElementById(
"lb_Community").style.display = "none";
        document.getElementById(
"dd_Community").style.display = "none";
    }

}

function selectCommunity()
{
    
if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

}

function addCommunity(community)
{
    communityList 
= document.getElementById("dd_Community");
    communityList.options[communityList.options.length] 
= new Option(community, community, falsefalse);
}

function buildQueryString()
{
    communityObject 
= document.getElementById("dd_Community");
    communityName 
= communityObject.options[communityObject.selectedIndex].value;
    cityOrTownObject 
= document.getElementById("dd_CityOrTown");
    cityOrTownName 
= cityOrTownObject.options[cityOrTownObject.selectedIndex].value;
    districtObject 
= document.getElementById("dd_District");
    districtName 
= districtObject.options[districtObject.selectedIndex].value;
    
var queryString;
    
if(communityName!="")//community
    {
        queryString 
= "community&^-^&"+cityOrTownName+"!^-^!"+districtName+"!^-^!"+communityName+"!^-^!"+minPrice+"!^-^!"+maxPrice+"!^-^!"+bedroom+"!^-^!"+bathroom+"!^-^!"+type+"!^-^!"+parking;
    }

    
else//town or district
    {
        
if(districtName=="")//town
        {
            queryString 
= "town&^-^&"+cityOrTownName+"!^-^!"+minPrice+"!^-^!"+maxPrice+"!^-^!"+bedroom+"!^-^!"+bathroom+"!^-^!"+type+"!^-^!"+parking;
        }

        
else//district
        {
            queryString 
= "district&^-^&"+cityOrTownName+"!^-^!"+districtName;
        }

    }

    
//alert(queryString);
    return queryString;
}

function isOKToSendRequest()
{
    cityObject 
= document.getElementById("dd_CityOrTown");
    cityName 
= cityObject.options[cityObject.selectedIndex].value;
    
if(cityName=="")
    
{
        
return false;
    }

    
else if(cityName == "Calgary" || cityName == "Edmonton")
    
{
        communityObject 
= document.getElementById("dd_Community");
        communityName 
= communityObject.options[communityObject.selectedIndex].value;
        
if(communityName=="")
        
{
            
return false;
        }

    }

    
else
    
{
        
return true;
    }

    
return true;
}

function MouseDownHandler(e, pointer, bar)//name left silde to xxx1, right slide to xxx2, but not 1 or 2 for single slide
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
    
var number = pointer.id.substring(pointer.id.length-1);
    
if(number == "1")
    
{
        currentLeftPointer 
= pointer;
        currentRightPointer 
= document.getElementById(pointer.id.substring(0, pointer.id.length-1)+"2");
        currentBar 
= bar;
        leftPointerMouseOffset 
= e.clientX - currentLeftPointer.offsetLeft;
        leftPointerDoDrag 
= true;
    }

    
else if(number == "2")
    
{
        currentRightPointer 
= pointer;
        currentLeftPointer 
= document.getElementById(pointer.id.substring(0, pointer.id.length-1)+"1");
        currentBar 
= bar;
        rightPointerMouseOffset 
= e.clientX - currentRightPointer.offsetLeft;
        rightPointerDoDrag 
= true;
    }

    
else
    
{
        currentSinglePointer 
= pointer;
        currentBar 
= bar;
        singlePointerMouseOffset 
= e.clientX - currentSinglePointer.offsetLeft;
        singlePointerDoDrag 
= true;
    }

}

function MouseMoveHandler(e)
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
if(leftPointerDoDrag)
    
{
        
var newPosition = e.clientX - leftPointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar);
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentRightPointer.offsetLeft - currentLeftPointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentLeftPointer,(newPosition 
- minLeft));
    }

    
else if(rightPointerDoDrag)
    
{
        
var newPosition = e.clientX - rightPointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar) + currentLeftPointer.offsetLeft + currentLeftPointer.offsetWidth;
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentBar.offsetWidth - currentRightPointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentRightPointer,(newPosition 
- minLeft + currentLeftPointer.offsetLeft + currentLeftPointer.offsetWidth));
    }

    
else if(singlePointerDoDrag)
    
{
        
var newPosition = e.clientX - singlePointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar);
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentBar.offsetWidth - currentSinglePointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentSinglePointer,(newPosition 
- minLeft));
    }

    setMinPrice();
    setMaxPrice();
    setBedroom();
    setBathroom();
    
return false;
}

function MouseUpHandler(e)
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
if(leftPointerDoDrag||rightPointerDoDrag||singlePointerDoDrag)
    
{
        leftPointerDoDrag 
= false;
        rightPointerDoDrag 
= false;
        singlePointerDoDrag 
= false;
        
if(isOKToSendRequest())
        
{
            sendRequest(buildQueryString());
        }

    }

}

document.onmousemove 
= MouseMoveHandler;
document.onmouseup 
= MouseUpHandler;
function getAbsoluteLeftPosition(object) 
{
    
var count = object.offsetLeft;
    
while(object.offsetParent!=null//recursive way to get the absolute location value
    {
        
var parent = object.offsetParent;
        count 
= count + parent.offsetLeft;
        object 
= parent;
    }

    
return count;
}

function setPosition(object,relativeLeftPosition) 
{
    object.style.left 
= relativeLeftPosition + "px";//relative
}
        
function getPercentageRangeForSlide(slider, bar)
{
    
return Math.round((slider.offsetLeft*100)/(bar.offsetWidth-slider.offsetWidth));
}

function setMinPrice()
{
    
var value = getPercentageRangeForSlide(priceSlide1,priceBar);
    minPrice 
= value*priceRange/100;
    document.getElementById("minPrice").innerText="min price:" + formatCurrency(minPrice);
}

function setMaxPrice()
{
    
var value = getPercentageRangeForSlide(priceSlide2,priceBar);
    
if(value==100)
    
{
        maxPrice
=6000000;
        document.getElementById(
"maxPrice").innerText="max price:$2M+";
    }

    
else
    
{
        maxPrice 
= value*priceRange/100;
        document.getElementById("maxPrice").innerText="max price:" + formatCurrency(maxPrice);
    }
  
}

function setBedroom()
{
    
var value = getPercentageRangeForSlide(bedroomSlide,bedroomBar);
    bedroom 
= Math.ceil(value*bedroomRange/100);
    //bedroom = value*bedroomRange/100;
    document.getElementById("bedroom").innerText="bedroom:" + bedroom;
}

function setBathroom()
{
    
var value = getPercentageRangeForSlide(bathroomSlide,bathroomBar);
    bathroom 
= Math.ceil(value*bathroomRange/100);
    //bathroom = value*bathroomRange/100;
    document.getElementById("bathroom").innerText="bathroom:" + bathroom;
}

function selectType()
{
    
var selectedList = document.getElementById("lb_Type");
    type 
= "";
    
for(var i =0;i<selectedList.length;i++)
    
{
        
if(selectedList.options[i].selected)
        
{
            type
=type+selectedList.options[i].value+"~^-^~";
        }

    }

    
if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

}

function selectParking()
{
    
var selectedList = document.getElementById("lb_Parking");
    parking
="";
    
for(var i =0;i<selectedList.length;i++)
    
{
        
if(selectedList.options[i].selected)
        
{
            parking
=parking+selectedList.options[i].value+"~^-^~";
        }

    }

    
if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

}

    
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
    
<form id="form1" runat="server">
       
<div id="minPrice" style="position:absolute;top:4px;left:4px;">min price:0</div>
        
<div id="maxPrice" style="position:absolute;top:4px;left:224px;">max price:2M+</div>
        
<div id="priceBar" style="position:absolute;top:24px;left:4px;width:200px;height:18px;background-image: url(Images/bgSlideBar(1).gif); background-repeat:repeat-x">
            
<div id="priceSlide1" style="position:absolute;top:0px;left:0px;width:10px;height:18px;cursor:pointer;cursor:hand;float:right;background-image: url(Images/icnSlider.gif)" onmousedown="MouseDownHandler(event, this, this.offsetParent)"></div>
            
<div id="priceSlide2" style="position:absolute;top:0px;left:190px;width:10px;height:18px;cursor:pointer;cursor:hand;float:right;background-image: url(Images/icnSlider.gif)" onmousedown="MouseDownHandler(event, this, this.offsetParent)"></div>
        
</div>
        
<div id="bedroom" style="position:absolute;top:54px;left:4px;">bedroom:0</div>
        
<div id="bedroomBar" style="position:absolute;top:74px;left:4px;width:200px;height:18px;background-image: url(Images/bgSlideBar(1).gif); background-repeat:repeat-x">
            
<div id="bedroomSlide" style="position:absolute;top:0px;left:0px;width:10px;height:18px;cursor:pointer;cursor:hand;float:right;background-image: url(Images/icnSlider.gif)" onmousedown="MouseDownHandler(event, this, this.offsetParent)"></div>
        
</div>
        
<div id="bathroom" style="position:absolute;top:104px;left:4px;">bathroom:0</div>
        
<div id="bathroomBar" style="position:absolute;top:124px;left:4px;width:200px;height:18px;background-image: url(Images/bgSlideBar(1).gif); background-repeat:repeat-x">
            
<div id="bathroomSlide" style="position:absolute;top:0px;left:0px;width:10px;height:18px;cursor:pointer;cursor:hand;float:right;background-image: url(Images/icnSlider.gif)" onmousedown="MouseDownHandler(event, this, this.offsetParent)"></div>
        
</div>
        
<div id="Type" style="position:absolute;top:154px;left:4px;">
            
<asp:ListBox runat="server" ID="lb_Type" SelectionMode="Multiple" onchange="selectType();">
            
</asp:ListBox>
        
</div>
        
<div id="Parking" style="position:absolute;top:254px;left:4px;">
            
<asp:ListBox runat="server" ID="lb_Parking" SelectionMode="Multiple" onchange="selectParking();">
            
</asp:ListBox>
        
</div>
        
<table>
        
<tr>
            
<td style="width: 800px">
            
</td>
            
<td>
                
<div id="mapinputs">
                    
<table>
                           
<tr>
                                
<td class="city">
                                    
<asp:Label ID="lb_CityOrTown" runat="server" CssClass="inputLabels" Text="City/Town:"></asp:Label>
                                    
<br />
                                    
<asp:DropDownList ID="dd_CityOrTown" runat="server" onChange="selectCityOrTown();" >
                                    
</asp:DropDownList>
                                
</td>
                                
<td class="district">
                                    
<asp:Label ID="lb_District" runat="server" CssClass="inputLabels" Text="District:" style="display:none"  ></asp:Label>
                                    
<br />        
                                    
<select id="dd_District" onChange="selectDistrict();" style="width: 55px;display:none">
                                        
<option selected="selected" value=""></option>
                                        
<option value="NW">NW</option>
                                        
<option value="NE">NE</option>
                                        
<option value="SE">SE</option>
                                        
<option value="SW">SW</option>
                                    
</select>
                                    
<asp:Label ID="lb_Community" runat="server" Text="Community:" style="display:none"></asp:Label>
                                    
<select id="dd_Community" style="display:none" onChange="selectCommunity();">
                                        
<option selected="selected"></option>
                                    
</select>
                                
</td>
                            
</tr>
                    
</table>
                
</div>
                
<div align="center" id="map_canvas" style="width: 500px; height: 500px"></div>
                
<div id="getDistance"></div>
                
<input type="button" name="GDirection" value="GDirection" id="GDirection" onclick="setDirections('784 Snediker Avenue Brooklyn NY', '12 5th Avenue New York, NY', 'en' );" />
          
</td>
            
</tr>
        
</table>
    
</form>
</body>
</html>


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Residential : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{
        
if (!Page.IsPostBack)
        
{           
            
this.dd_CityOrTown.Items.Add("");
            
this.dd_CityOrTown.Items.Add("Calgary");
            
this.dd_CityOrTown.Items.Add("Edmonton");
            ListItem li;
            SqlConnection conn 
= new SqlConnection();
            conn.ConnectionString 
= ConfigurationManager.ConnectionStrings["ConnectionInfo"].ConnectionString;
            conn.Open();
            SqlCommand comm 
= new SqlCommand();
            comm.Connection 
= conn;
            comm.CommandText 
= "select distinct areadesc from res_idx where ((areadesc <> 'Calgary') and (areadesc <> 'Edmonton')) order by areadesc";
            SqlDataAdapter da 
= new SqlDataAdapter();
            da.SelectCommand 
= comm;
            DataTable dt 
= new DataTable();
            da.Fill(dt);
            
foreach (DataRow dr in dt.Rows)
            
{
                li 
= new ListItem();
                li.Text 
= dr[0].ToString().Trim();
                li.Value 
= dr[0].ToString().Trim();
                
this.dd_CityOrTown.Items.Add(li);
            }

            
//type
            this.lb_Type.Items.Add("");
            comm.CommandText 
= "SELECT distinct RTRIM(LTRIM([type1])) as type1 FROM [RES_IDX] order by RTRIM(LTRIM([type1]))";
            da 
= new SqlDataAdapter();
            da.SelectCommand 
= comm;
            dt 
= new DataTable();
            da.Fill(dt);
            
foreach (DataRow dr in dt.Rows)
            
{
                li 
= new ListItem();
                li.Text 
= dr[0].ToString().Trim();
                li.Value 
= dr[0].ToString().Trim();
                
this.lb_Type.Items.Add(li);
            }

            
//parking
            this.lb_Parking.Items.Add("");
            comm.CommandText 
= "SELECT distinct RTRIM(LTRIM([Parking])) as Parking FROM [RES_IDX] order by RTRIM(LTRIM([Parking]))";
            da 
= new SqlDataAdapter();
            da.SelectCommand 
= comm;
            dt 
= new DataTable();
            da.Fill(dt);
            
foreach (DataRow dr in dt.Rows)
            
{
                li 
= new ListItem();
                li.Text 
= dr[0].ToString().Trim();
                li.Value 
= dr[0].ToString().Trim();
                
this.lb_Parking.Items.Add(li);
            }

            conn.Close();
        }

    }

}


using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;

public partial class Search : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{
        
try
        
{
            
string search;
            
//search = "community&^-^&Chestermere!^-^!0!^-^!6000000!^-^!0!^-^!0!^-^!0!^-^!not set!^-^!rio~^-^~dfdf~^-^~";
            search = this.Request.Form["Search"].ToString();
            
string[] columns = System.Text.RegularExpressions.Regex.Split(search, "\\&\\^\\-\\^\\&");
            StringBuilder sb 
= new StringBuilder();
            SqlConnection conn 
= new SqlConnection();
            conn.ConnectionString 
= ConfigurationManager.ConnectionStrings["ConnectionInfo"].ConnectionString;
            conn.Open();
            SqlCommand comm 
= new SqlCommand();
            comm.Connection 
= conn;
            
if (columns[0== "town")
            
{
                
string[] array = System.Text.RegularExpressions.Regex.Split(columns[1], "\\!\\^\\-\\^\\!");
                sb.Append(
"select distinct zipcode from res_idx where areadesc like '%' + @area + '%'");
                comm.Parameters.AddWithValue(
"@area", array[0].Trim());
                sb.Append(
" and (lprice>=@minPrice and lprice<=@maxPrice) and (beds>@beds) and (baths>@baths) ");
                comm.Parameters.AddWithValue(
"@minPrice", array[1].Trim());
                comm.Parameters.AddWithValue(
"@maxPrice", array[2].Trim());
                comm.Parameters.AddWithValue(
"@beds", array[3].Trim());
                comm.Parameters.AddWithValue(
"@baths", array[4].Trim());
                
if (array[5].Trim() != "")
                
{
                    
string[] types = System.Text.RegularExpressions.Regex.Split(array[5], "\\~\\^\\-\\^\\~");
                    
if (types[0].Trim() != "")
                    
{
                        sb.Append(
" and  (type1 = @typePara0");
                        comm.Parameters.AddWithValue(
"@typePara0", types[0].Trim());
                        
for (int i = 1; i < types.Length; i++)
                        
{
                            
if (types[i].Trim() != "")
                            
{
                                sb.Append(
" or type1= @typePara" + i.ToString() + " ");
                                comm.Parameters.AddWithValue(
"@typePara" + i.ToString(), types[i].Trim());
                            }

                        }

                        sb.Append(
"");
                    }

                }

                
if (array[6].Trim() != "")
                
{
                    
string[] parkings = System.Text.RegularExpressions.Regex.Split(array[6], "\\~\\^\\-\\^\\~");
                    
if (parkings[0].Trim() != "")
                    
{
                        sb.Append(
" and (parking like '%' + @parkingPara0 + '%'");
                        comm.Parameters.AddWithValue(
"@parkingPara0", parkings[0].Trim());
                        
for (int i = 1; i < parkings.Length; i++)
                        
{
                            
if (parkings[i].Trim() != "")
                            
{
                                sb.Append(
" or parking  like '%' + @parkingPara" + i.ToString() + "+'%' ");
                                comm.Parameters.AddWithValue(
"@parkingPara" + i.ToString(), parkings[i].Trim());
                            }

                        }

                        sb.Append(
"");
                    }

                }

                comm.CommandText 
= sb.ToString();
                SqlDataAdapter da 
= new SqlDataAdapter();
                da.SelectCommand 
= comm;
                DataTable dt 
= new DataTable();
                da.Fill(dt);
                sb 
= new StringBuilder();
                
//foreach (DataRow dr in dt.Rows)
                
//{
                
//    sb.AppendLine("setGoogleMapLocations('" + dr[0].ToString().Trim() + ", alberta, canada');");
                
//}
                
//sb.AppendLine("setGoogleMapTown('" + dt.Rows[new Random().Next(0, dt.Rows.Count - 1)][0].ToString().Trim() + ", alberta, canada');");
                sb.Append("buildList('");
                
foreach (DataRow dr in dt.Rows)
                
{
                    sb.Append(dr[
0].ToString().Trim() + ", alberta, canada-");
                }

                sb.Append(
"');");
            }

            
else if (columns[0== "district")
            
{
                
string[] array = System.Text.RegularExpressions.Regex.Split(columns[1], "\\!\\^\\-\\^\\!");
                
string city = array[0];
                
string district = array[1];
                comm.CommandText 
= "select distinct communityD from res_idx where areaDesc = @city and streetdir = @district order by communityD";
                comm.Parameters.AddWithValue(
"@city",city.Trim());
                comm.Parameters.AddWithValue(
"@district",district.Trim());
                SqlDataAdapter da 
= new SqlDataAdapter();
                da.SelectCommand 
= comm;
                DataTable dt 
= new DataTable();
                da.Fill(dt);
                
for (int i = 0; i < dt.Rows.Count; i++)
                
{
                    sb.AppendLine(
"addCommunity('" + dt.Rows[i][0].ToString() + "')");
                }

            }

            
else if (columns[0== "community")
            
{
                
string[] array = System.Text.RegularExpressions.Regex.Split(columns[1], "\\!\\^\\-\\^\\!");
                comm.Parameters.AddWithValue(
"@city", array[0].Trim());
                comm.Parameters.AddWithValue(
"@district", array[1].Trim());
                comm.Parameters.AddWithValue(
"@community", array[2].Trim());
                sb.Append(
"select distinct zipcode from res_idx where areaDesc = @city and streetdir = @district and communityD=@community");
                sb.Append(
" and (lprice>=@minPrice and lprice<=@maxPrice) and (beds>@beds) and (baths>@baths) ");
                comm.Parameters.AddWithValue(
"@minPrice", array[3].Trim());
                comm.Parameters.AddWithValue(
"@maxPrice", array[4].Trim());
                comm.Parameters.AddWithValue(
"@beds", array[5].Trim());
                comm.Parameters.AddWithValue(
"@baths", array[6].Trim());
                
if (array[7].Trim() != "")
                
{
                    
string[] types = System.Text.RegularExpressions.Regex.Split(array[7], "\\~\\^\\-\\^\\~");
                    
if (types[0].Trim() != "")
                    
{
                        sb.Append(
" and  (type1 = @typePara0");
                        comm.Parameters.AddWithValue(
"@typePara0", types[0].Trim());
                        
for (int i = 1; i < types.Length; i++)
                        
{
                            
if (types[i].Trim() != "")
                            
{
                                sb.Append(
" or type1= @typePara" + i.ToString() + " ");
                                comm.Parameters.AddWithValue(
"@typePara" + i.ToString(), types[i].Trim());
                            }

                        }

                        sb.Append(
"");
                    }

                }

                
if (array[8].Trim() != "")
                
{
                    
string[] parkings = System.Text.RegularExpressions.Regex.Split(array[8], "\\~\\^\\-\\^\\~");
                    
if (parkings[0].Trim() != "")
                    
{
                        sb.Append(
" and (parking like '%' + @parkingPara0 + '%'");
                        comm.Parameters.AddWithValue(
"@parkingPara0", parkings[0].Trim());
                        
for (int i = 1; i < parkings.Length; i++)
                        
{
                            
if (parkings[i].Trim() != "")
                            
{
                                sb.Append(
" or parking  like '%' + @parkingPara" + i.ToString() + "+'%' ");
                                comm.Parameters.AddWithValue(
"@parkingPara" + i.ToString(), parkings[i].Trim());
                            }

                        }

                        sb.Append(
"");
                    }

                }

                comm.CommandText 
= sb.ToString();
                
//WriteFile("c:/ri3.txt", sb.ToString());
                sb = new StringBuilder();
                SqlDataAdapter da 
= new SqlDataAdapter();
                da.SelectCommand 
= comm;
                DataTable dt 
= new DataTable();
                da.Fill(dt);
                
//foreach (DataRow dr in dt.Rows)
                
//{
                
//    sb.AppendLine("setGoogleMapLocations('" + dr[0].ToString().Trim() + ", alberta, canada');");
                
//}
                
//sb.AppendLine("setGoogleMapCommunity('" + dt.Rows[new Random().Next(0, dt.Rows.Count - 1)][0].ToString().Trim() + ", alberta, canada');");
                sb.Append("buildList('");
                
foreach (DataRow dr in dt.Rows)
                
{
                    sb.Append(dr[
0].ToString().Trim() + ", alberta, canada-");
                }

                sb.Append(
"');");
            }

            conn.Close();
            
//WriteFile("c:/ri2.txt", sb.ToString());
            this.Response.Write(sb.ToString());
            
this.Response.End();
        }

        
catch
        
{
            
this.Response.End();
        }

    }

    
private void WriteFile(string filePath, string content)
    
{
        
using (StreamWriter sw = new StreamWriter(filePath))
        
{
            sw.Write(content);
        }

    }

}

posted @ 2008-01-30 07:57  N/A2011  阅读(293)  评论(0编辑  收藏  举报