
gotham.geo = new Object();


function findOtherPOIs( map )
{
    var bounds = map.getBounds();
    var bsw = bounds.getSouthWest();
    var bne = bounds.getNorthEast();

    var callback = function (data, textStatus) {
        if( textStatus == 'success' )
        {
            var mymap = map;
            for( var myPOI in data.placeList )
            {
                if( gotham.geo[ mymap.getContainer().id ][ data[myPOI].id ]==undefined )
                {
                    addPoiMarker(data[myPOI],map);
                }
            }
        }
    }

    var data = {'sw':bsw.toUrlValue(),'ne':bne.toUrlValue()};
    $.post("/search/rect.json", data, callback, "json");
}

function addPoiMarker( poi , map )
{
    if( gotham.geo[ map.getContainer().id ][ poi.id ]!=true )
    {
        var mycon = new GIcon(G_DEFAULT_ICON);
        var mChar = poi.cat.charAt(0);
        mycon.image = "http://www.google.com/mapfiles/marker"+mChar+".png";

        var point = new GLatLng(poi.latitude,poi.longitude);
        var marker = new GMarker(point,{icon:mycon});
		
		var poihtml = "<div><strong><a href='/place/"+poi.id+"'>"+poi.title+"</a></strong><br>";
			poihtml+= ""+poi.street+" "+poi.streetnbr+"<br>";
			poihtml+= ""+poi.zipcode+" "+poi.city+"</div>";
		
        marker.bindInfoWindowHtml(poihtml);

        map.addOverlay(marker);
        gotham.geo[ map.getContainer().id ][ poi.id ]=true;
    }
}
