/** * this file contains the entire javascript part of the interactive map */ window.pmap = function() { }; loader = new YAHOO.util.YUILoader(); loader.require("event", "container", "dragdrop"); loader.loadOptional = true; loader.insert(function() { pmap.mapW = 663; pmap.mapH = 678; pmap.pinMarkup = '
'; pmap.altPinMarkup = ''; pmap.pmapPropList = new Array(); /** * presents user with interface to select location on map for */ pmap.selectLocation = function(passedList) { if(document.getElementById('PmapPropCategory').value == 'Sales' && passedList != null) { pmapPropList = passedList[0]; } else if (document.getElementById('PmapPropCategory').value == 'Rentals' && passedList != null) { pmapPropList = passedList[1]; } else { var pmapPropList; var edit = true; } if(xEl = document.getElementById('PmapPropLocX')) x = (xEl.value.length > 0) ? parseInt(xEl.value) : 0; if(yEl = document.getElementById('PmapPropLocY')) y = (yEl.value.length > 0) ? parseInt(yEl.value) : 0; if(!pmap.panel) { pmap.panel = new YAHOO.widget.Panel("selectLocationPanel", { x: 200, y: 100, underlay: 'none', close: true, visible: false } ); pmap.panel.setBody('Drag the pin to desired the location then close the selection window.
' + '
';
}
*/
containerX = YAHOO.util.Dom.getX(pinContainerEl);
containerY = YAHOO.util.Dom.getY(pinContainerEl);
tmpEl = document.createElement('div');
for(pmapPropListK in pmapPropList)
{
pmapProp = pmapPropList[pmapPropListK];
if(typeof(pmapProp['PmapProp']) != 'undefined')
{
var pinElId = 'pmapPin' + pmapPropListK;
tmpEl.innerHTML = pmap.altPinMarkup.replace('%attribs%', 'id="'+pinElId+'"');
pinEl = tmpEl.firstChild;
pinEl.pmapProp = pmapProp;
pinContainerEl.appendChild(pinEl);
YAHOO.util.Dom.setX(pinEl, parseInt(pmapProp['PmapProp']['loc_x']) + containerX);
YAHOO.util.Dom.setY(pinEl, parseInt(pmapProp['PmapProp']['loc_y']) + containerY);
}
}
delete tmpEl;
// End loop
YAHOO.util.Dom.setX(document.getElementById('pmapPin'),
YAHOO.util.Dom.getX(document.getElementById('pmapMapContainer'))+x);
YAHOO.util.Dom.setY(document.getElementById('pmapPin'),
YAHOO.util.Dom.getY(document.getElementById('pmapMapContainer'))+y);
pmap.dd1.setXConstraint(x, pmap.mapW-x, 1);
pmap.dd1.setYConstraint(y, pmap.mapH-y, 1);
pmap.panel.show();
}
/**
* displays map with hoverable property pins
*/
pmap.showMap = function(pmapPropList)
{
pmap.pmapPropList = pmapPropList;
containerX = YAHOO.util.Dom.getX(document.getElementById('pmapMapContainer'));
containerY = YAHOO.util.Dom.getY(document.getElementById('pmapMapContainer'));
pinContainerEl = document.getElementById('pmapPinContainer');
pmapPropListEl = document.getElementById('pmapPropList');
tmpEl = document.createElement('div');
// loop properties
for(pmapPropListK in pmapPropList)
{
pmapProp = pmapPropList[pmapPropListK];
if(typeof(pmapProp['PmapProp']) != 'undefined')
{
var pinElId = 'pmapPin' + pmapPropListK;
tmpEl.innerHTML = pmap.pinMarkup.replace('%attribs%', 'id="'+pinElId+'"');
pinEl = tmpEl.firstChild;
pinEl.pmapProp = pmapProp;
pinContainerEl.appendChild(pinEl);
YAHOO.util.Event.addListener(pinEl, 'click', pmap.pinClicked);
YAHOO.util.Dom.setX(pinEl, parseInt(pmapProp['PmapProp']['loc_x']) + containerX);
YAHOO.util.Dom.setY(pinEl, parseInt(pmapProp['PmapProp']['loc_y']) + containerY);
// add to list
pmapPropListItemEl = document.createElement('li');
pmapPropListItemEl.appendChild(pmapPropLinkEl = document.createElement('a'));
pmapPropLinkEl.href = 'javascript:pmap.clickPin(document.getElementById(\'pmapPin' + parseInt(pmapPropListK) + '\'));';
if(document.all)
{
pmapPropLinkEl.innerText = pmapProp['PmapProp']['name'];
}
else
{
pmapPropLinkEl.textContent = pmapProp['PmapProp']['name'];
}
pmapPropListEl.appendChild(pmapPropListItemEl);
}
}
delete tmpEl;
}
pmap.pinClicked = function()
{
pmap.clickPin(this);
}
pmap.closePin = function(pinId)
{
var pinDetail = document.getElementById(pinId+'Detail');
pinDetail.style.display='none';
var pinEl = document.getElementById(pinId);
pinEl.style.backgroundImage = 'url(/lib24watch/plugin_img/pmap/pin.gif)';
pinEl.style.width = '8px';
pinEl.style.height = '11px';
}
pmap.clickPin = function(pinEl)
{
pinContainerEl = document.getElementById('pmapPinContainer');
// detail element doesn't exist yet, so create & show
if(!(detailEl = document.getElementById(detailElId=pinEl.id+'Detail')))
{
pinContainerEl.appendChild(detailEl = document.createElement('div'));
detailEl.id = detailElId;
detailEl.style.zIndex = 2;
detailEl.style.position = 'absolute';
detailEl.className = 'pmapDetail';
detailEl.innerHTML = '