//'+name+'';
var i2=i;
GEvent.addListener(marker, "click", function() {
if (map.getZoom() < 16) {
map.setCenter(marker.getPoint(), 9);
//map.setZoom(9);
marker.openInfoWindowHtml(html
+ '
');
} else {
marker.openInfoWindowHtml(html
+ '');
}
});
gmarkers[i] = marker;
htmls[i] = html;
side_bar_html +=
'';
side_bar_html +=
'
';
side_bar_html +='
'+type+'
';
side_bar_html +='
'+picture+'
';
side_bar_html +='
'+ psize +'
';
side_bar_html +='
'+ bsize +'
';
side_bar_html +='
'+ price +'
';
side_bar_html +='
'+ web +'
';
side_bar_html +='
'+ code +'
';
side_bar_html +='
';
// ====== The new marker "mouseover" and "mouseout" listeners ======
GEvent.addListener(marker,"mouseover", function() {
showTooltip(marker);
});
GEvent.addListener(marker,"mouseout", function() {
tooltip.style.visibility="hidden"
});
i++;
return marker;
}
// ====== This function displays the tooltip ======
function showTooltip(marker) {
tooltip.innerHTML = marker.tooltip;
var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
var anchor=marker.getIcon().iconAnchor;
var width=marker.getIcon().iconSize.width;
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y));
pos.apply(tooltip);
tooltip.style.visibility="visible";
}
function zoomIn(i){
map.setCenter(gmarkers[i].getPoint(), 16);
map.setMapType(G_SATELLITE_MAP);
GEvent.trigger(gmarkers[i], "click");
}
function zoomOut(i){
map.setCenter(gmarkers[i].getPoint(), 10);
map.setMapType(G_NORMAL_MAP);
GEvent.trigger(gmarkers[i], "click");
}
// It launches the tooltip on the icon sidebar
function mymouseover(i) {
showTooltip(gmarkers[i]);
}
// It hides the tooltip from sidebar
function mymouseout() {
tooltip.style.visibility="hidden";
}
// This function picks up the sidebar click and opens the corresponding info window
function myclick(i) {
map.setCenter(gmarkers[i].getPoint(), 9);
//map.setZoom(9);
if (map.getZoom() < 16) {
gmarkers[i].openInfoWindowHtml(htmls[i]+ '');
} else {
gmarkers[i].openInfoWindowHtml(htmls[i]+ '');
}
}
function submitform() {
document.myform.submit();
}
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var boxStyleOpts = {
opacity: .2,
border: "2px solid red"
}
/* second set of options is for everything else */
var otherOpts = {
buttonHTML: "
",
buttonZoomingHTML: "
",
buttonStartingStyle: {width: '24px', height: '24px'}
};
map.addControl(new DragZoomControl(boxStyleOpts, otherOpts));
map.setCenter(new GLatLng(35.241113,24.906006),8);
// ===== Start with an empty GLatLngBounds object =====
var bounds = new GLatLngBounds();
// ====== set up marker mouseover tooltip div ======
var tooltip = document.createElement("div");
document.getElementById("map").appendChild(tooltip);
tooltip.style.visibility="hidden";
function handleSelected(opt) {
var url = xmlfile[opt.selectedIndex];
readMap(url);
}
function readMap(url) {
var request = GXmlHttp.create();
request.open("GET", url, true); // request XML from PHP with AJAX call
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = GXml.parse(request.responseText);
// obtain the array of markers and loop through it
i=[0];
markers=[0];
markers = xmlDoc.documentElement.getElementsByTagName("Placemark");
map.getInfoWindow().hide();
gmarkers = [];
map.clearOverlays();
side_bar_html = "";
var bounds = new GLatLngBounds();
window.setTimeout(startmap,timeOut1);
}
}
request.send(null);
}
function startmap() {
if ( ii < markers.length ) {
var keep=Math.min(ii + 10, markers.length);
while (ii < keep) {
var coords=GXml.value(markers[i].getElementsByTagName("coordinates")[0]);
coords=coords.replace(/\s+/g," "); // tidy the whitespace
coords=coords.replace(/^ /,""); // remove possible leading whitespace
coords=coords.replace(/, /,","); // tidy the commas
var path = coords.split(" ");
var bits = path[0].split(",");
var point = new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));
var name=GXml.value(markers[i].getElementsByTagName("name")[0]);
var desc=GXml.value(markers[i].getElementsByTagName("description")[0]);
var html =''+desc;
var label = name;
var cdat=GXml.value(markers[i].getElementsByTagName("description")[0]);
cdat=cdat.replace(/\s+/g," ");
cdat=cdat.replace(/^ /,"");
cdat=cdat.replace(/, /,",");
cdat=cdat.replace(/> ^<");
var cdatresult = cdat.split("^");
var picture=cdatresult[3].replace(/>^<");picture=picture.split("^");picture=picture[1];
var psize =cdatresult[4].split("");psize=psize[0].split(">");psize=psize[1];
var bsize =cdatresult[5].split("");bsize=bsize[0].split(">");bsize=bsize[1];
var price =cdatresult[6].split("");price=price[0].split(">");price=price[1];
var code =cdatresult[7].split(""); code=code[0].split(">");code = code[1];
var type =cdatresult[2].split(""); type=type[0].split(">");type = type[1];
var web =cdatresult[8].replace(/>^<");web=web.split("^"); web=web[1];
var back = name;
var style=GXml.value(markers[i].getElementsByTagName("styleUrl")[0]);
var icontype =style;
if(icontype == "#1Style"){
var color ="green";
}else if(icontype == "#2Style"){
var color ="blue";
}else if(icontype == "#4Style"){
var color ="white";
} else {
var color ="yellow";
}
var icontype = color;
// create the marker
var marker = createMarker(point,label,html,icontype,type,picture,psize,bsize,price,web,code,back);
map.addOverlay(marker);
bounds.extend(point);
ii++;
}
if (document.getElementById('loadingMessage')) {
document.getElementById('loading').style.visibility='visible';
document.getElementById('loadingMessage').innerHTML = 'Loading Markers...
' + ii + ' of ' + markers.length+ '
';
}
window.setTimeout(startmap,timeOut);
}
else {
document.getElementById("sidebar").innerHTML = side_bar_html;
document.getElementById('loading').style.visibility='hidden';
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
map.setMapType(G_NORMAL_MAP);
ii=0;
}
}
// When initially loaded, use this data
readMap("http://www.cretanadvice.co.uk/property/mapdatak_start.php");
//Define and set position of Counterbox
var loading = document.getElementById("loading");
pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(180,60));
pos.apply(loading);
map.getContainer().appendChild(loading);
} else
{alert("Sorry, the Google Maps API is not compatible with this browser");}
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://econym.googlepages.com/index.htm
// Written by Ralph Ames at
// www.easypagez.com
// ralph.ames@gmail.com
//]]>