var map = false;
var showimages = true;
function initMap(lng,lat,title,desc) {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(lat,lng), 12);
map.addMapType(G_PHYSICAL_MAP);
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.enableScrollWheelZoom();
var coords = new GLatLng(lat,lng);
var marker = new GMarker(coords);
map.addOverlay(marker);
var txt = ""+title+"
"+desc;
GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(txt);});
GEvent.addListener(map, "clearoverlays", function(){map.addOverlay(marker);GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(txt);});});
marker.openInfoWindowHtml(txt);
if(showimages){
fetchPictures();
}
/*
map.setMapType(G_PHYSICAL_MAP);
GEvent.addListener(map, "zoomend", fetchPictures);
GEvent.addListener(map, "dragend", fetchPictures);
*/
}
}
function initServiceMap(lng,lat,title,desc) {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(lat,lng), 12);
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.enableScrollWheelZoom();
var coords = new GLatLng(lat,lng);
var marker = new GMarker(coords);
map.addOverlay(marker);
var txt = ""+title+"
"+desc;
GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(txt);});
GEvent.addListener(map, "clearoverlays", function(){map.addOverlay(marker);GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(txt);});});
marker.openInfoWindowHtml(txt);
if(showimages){
fetchPictures();
}
/*
GEvent.addListener(map, "zoomend", fetchPictures);
GEvent.addListener(map, "dragend", fetchPictures);
*/
}
}
function fetchService(c,sc) {
}
function fetchPictures(){
if(showimages){
var mb = map.getBounds();
var sw = mb.getSouthWest();
var ne = mb.getNorthEast();
var minY = sw.lat();
var minX = sw.lng();
var maxY = ne.lat();
var maxX = ne.lng();
$.getJSON("http://www.world-geographics.com/cfg/public/_php/fetchpictures.php", "minx="+minX+"&maxx="+maxX+"&miny="+minY+"&maxy="+maxY, addPictures) ;
}
}
function cleanUpPictures(){
map.clearOverlays();
}
function createMarker(point,html,icon) {
var marker = new GMarker(point,icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
function showImage(url,title,disclaimer){
$('#imagepopup').remove();
var pop = document.createElement("div");
pop.className = "viewimg";
pop.id = "imagepopup";
$(pop).append("
Close this window »
"); $(document.body).append(pop); var win = getWindowSize(); var scroll = getScrollXY(); var top = Math.round(scroll[1] + 120); var left = Math.round((win[1] / 3) + scroll[0]); pop.style.top = top+"px"; pop.style.left = left+"px"; } function addPictures(p){ cleanUpPictures(); var numpics = $(p).attr('count'); var photos = $(p).attr('photos'); var numexp = /^[\d]+$/; if(typeof numpics != "undefined" && numpics != "undefined" && numexp.test(numpics)){ $('#tab_images').html("Images ("+numpics+")"); } count=0; $.each(photos,function(i,v){ if(count == 0){ txt = ""; $.each(v,function(n,s){ txt += n+" = "+s+"\n"; }); /*alert(txt);*/ } count++; var lng = $(v).attr('longitude'); var lat = $(v).attr('latitude'); var title = $(v).attr('photo_title'); if(title == "undefined"){title = "Image";} var imgurl = $(v).attr('photo_file_url'); var thumbexp = /medium/; var thumburl = imgurl.replace(thumbexp,"thumbnail"); var imgowner = $(v).attr('owner_name'); var imgownerurl = $(v).attr('owner_url'); var imgX = $(v).attr('width'); var imgY = $(v).attr('height'); var disclaimer = "Author of image: "+imgowner+""; var imgIc = new GIcon(); imgIc.iconSize=new GSize(24,24); imgIc.shadowSize=new GSize(0,0); imgIc.iconAnchor=new GPoint(16,32); imgIc.infoWindowAnchor=new GPoint(16,0); var ic = new GIcon(imgIc, "http://maps.google.com/mapfiles/kml/pal4/icon46.png", null, "http://maps.google.com/mapfiles/kml/pal4/icon46s.png"); var point = new GLatLng(lat,lng); var marker = new GMarker(point,ic); GEvent.addListener(marker, "click", function() { showImage(imgurl,title,disclaimer); }); map.addOverlay(marker); var li = document.createElement("li"); li.className = "cursorpointer"; li.innerHTML = title; $("#tab_images_content").append(li); $(li).bind("click",function(e){showImage(imgurl,title,disclaimer);}); /* "photo_id": 532693, "photo_title": "Wheatfield in afternoon light", "photo_url": "http://www.panoramio.com/photo/532693", "photo_file_url": "http://static2.bareka.com/photos/medium/532693.jpg", "longitude": 11.280727, "latitude": 59.643198, "width": 500, "height": 333, "upload_date": "22 January 2007", "owner_id": 39160, "owner_name": "Snemann", "owner_url": "http://www.panoramio.com/user/39160", */ }); } function getOffset(o){if(isset(o) && isset(o.offsetParent)){var cl,ct;cl=0;ct=0;if (o.offsetParent) {cl = o.offsetLeft;ct = o.offsetTop;while (o = o.offsetParent) {cl += o.offsetLeft;ct += o.offsetTop;}}return [cl,ct];}else{return false;}} function getScrollXY() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [ scrOfX, scrOfY ]; } function getWindowSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return [ myWidth, myHeight ]; }