var centreLat=0.0; var centreLon=0.0; var initialZoom=1; var imageWraps=false; //SET THIS TO false TO PREVENT THE IMAGE WRAPPING AROUND var map; //the GMap2 itself ///////////////////// //Custom projection ///////////////////// function CustomProjection(a,b){ this.imageDimension=65536; this.pixelsPerLonDegree=[]; this.pixelOrigin=[]; this.tileBounds=[]; this.tileSize=256; this.isWrapped=b; var b=this.tileSize; var c=1; for(var d=0;d= tileBounds) {return false;} if (this.isWrapped) { if (tile.x<0 || tile.x>=tileBounds) { tile.x = tile.x%tileBounds; if (tile.x < 0) {tile.x+=tileBounds} } } else { if (tile.x<0 || tile.x>=tileBounds) {return false;} } return true; } CustomProjection.prototype.getWrapWidth=function(zoom) { return this.tileBounds[zoom]*this.tileSize; } //////////////////////////////////////////////////////////////////////////// function customGetTileURL(a,b) { //converts tile x,y into keyhole string var c=Math.pow(2,b); var d=a.x; var e=a.y; var f="t"; for(var g=0;g=0) { d.style.height=height+"px"; } } function load() { if (GBrowserIsCompatible()) { //resizeMapDiv(); var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, "CASA"); var copyrightCollection = new GCopyrightCollection("GMapImgCutter"); copyrightCollection.addCopyright(copyright); //create a custom picture layer var pic_tileLayers = [ new GTileLayer(copyrightCollection , 0, 17)]; pic_tileLayers[0].getTileUrl = customGetTileURL; pic_tileLayers[0].isPng = function() { return false; }; pic_tileLayers[0].getOpacity = function() { return 1.0; }; var proj=new CustomProjection(4,imageWraps); var pic_customMap = new GMapType(pic_tileLayers, proj, "Pic", {maxResolution:3, minResolution:1, errorMessage:"Data not available"}); //Now create the custom map. Would normally be G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP // map = new GMap2(document.getElementById("map"),{backgroundColor: "white", mapTypes:[pic_customMap]}); map = new GMap2(document.getElementById("map"),{backgroundColor: "transparent", mapTypes:[pic_customMap]}); controlPos1 = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(-10,-60)); controlPos2 = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0,0)); controls1 = new GLargeMapControl3D(); controls = map.addControl(controls1, controlPos1); // map.addControl(new GMapTypeControl()); // controls = map.addControl(new GSmallZoomControl3D); // GOverviewMapControl is the thumbnail map // map.addControl(new GOverviewMapControl()); map.enableDoubleClickZoom(); map.enableContinuousZoom(); map.enableScrollWheelZoom(); map.disableDragging(); map.setCenter(new GLatLng(centreLat, centreLon), initialZoom, pic_customMap); //alert(map.getBounds()); zoomListener = GEvent.addListener(map,"zoomend",function(oldLevel, newLevel) { //alert(newLevel); if (newLevel > 1) { map.enableDragging(); map.removeControl(controls1); controls = map.addControl(controls1, controlPos2); } else { map.disableDragging(); map.setCenter(new GLatLng(centreLat, centreLon)); map.removeControl(controls1); controls = map.addControl(controls1, controlPos1); } // Add a move listener to restrict the bounds range moveListener = GEvent.addListener(map, "move", function() { checkBounds(); }); // The allowed region which the whole map must be within var allowedBounds = new GLatLngBounds(new GLatLng((-73.125/2.1),(-180/2.1)), new GLatLng((73.125/2.1),(180/2.1))); // If the map position is out of range, move it back function checkBounds() { // Perform the check and return if OK if (allowedBounds.contains(map.getCenter())) { return; } // It`s not OK, so find the nearest allowed point and move there var C = map.getCenter(); var X = C.lng(); var Y = C.lat(); var AmaxX = allowedBounds.getNorthEast().lng(); var AmaxY = allowedBounds.getNorthEast().lat(); var AminX = allowedBounds.getSouthWest().lng(); var AminY = allowedBounds.getSouthWest().lat(); if (X < AminX) {X = AminX;} if (X > AmaxX) {X = AmaxX;} if (Y < AminY) {Y = AminY;} if (Y > AmaxY) {Y = AmaxY;} //alert ("Restricting "+Y+" "+X); map.setCenter(new GLatLng(Y,X)); } }); /* This allows the user to add points on click. Do not want for production. lstner = GEvent.addListener(map, 'click', function(overlay, point){ var pointA = new GPoint(point.x, point.y); var mark = new GMarker(pointA); map.addOverlay(mark); //map.centerAtLatLng(point); GEvent.addListener(mark, 'click', function(){ mark.openInfoWindowHtml(point.y+"," + point.x); }); mark.openInfoWindowHtml(point.y+"," + point.x); });*/ var excalibur = new GIcon(); excalibur.image = "excalibur/excalibur.png"; excalibur.iconSize = new GSize(30,30); excalibur.shadow = "excalibur/excalibur_shadow.png"; excalibur.shadowSize = new GSize(30,30); excalibur.iconAnchor = new GPoint(1,30); excalibur.infoWindowAnchor = new GPoint(15,15); excalibur.transparent = "excalibur/excalibur_transparent.png"; excalibur.printImage = "excalibur/excalibur.gif"; excalibur.mozPrintImage = "excalibur/excalibur_notrans.gif"; excalibur.printShadow = "excalibur/excalibur_printshadow.gif"; ///////////////////////////////////////////////////////////////////////////////////// //Add any markers here e.g. // map.addOverlay(new GMarker(new GLatLng(x,y))); /////////////////////////////////////////////////////////////////////////////////////\ markers = []; markers[0] = new GMarker(new GLatLng(1.845703125,-5.625),excalibur); markers[1] = new GMarker(new GLatLng(-24.43359375,18.28125),excalibur); markers[2] = new GMarker(new GLatLng(-37.705078125,33.046875),excalibur); markers[3] = new GMarker(new GLatLng(4.21875,39.7265625),excalibur); markers[4] = new GMarker(new GLatLng(17.490234375,41.8359375),excalibur); markers[5] = new GMarker(new GLatLng(23.115234375,-43.76953125),excalibur); markers[6] = new GMarker(new GLatLng(-6.15234375,30.41015625),excalibur); markers[7] = new GMarker(new GLatLng(-42.1875,98.4375),excalibur); markers[8] = new GMarker(new GLatLng(27.685546875,24.9609375),excalibur); markers[9] = new GMarker(new GLatLng(-7.822265625,56.953125),excalibur); markers[10] = new GMarker(new GLatLng(-1.93359375,-32.16796875),excalibur); markers[11] = new GMarker(new GLatLng(15.1171875,75.234375),excalibur); markers[12] = new GMarker(new GLatLng(30.76171875,-80.15625),excalibur); markers[13] = new GMarker(new GLatLng(2.197265625,-90),excalibur); markers[14] = new GMarker(new GLatLng(4.306640625,110.56640625),excalibur); markers[15] = new GMarker(new GLatLng(12.12890625,-2.8125),excalibur); markers[16] = new GMarker(new GLatLng(-46.142578125,5.2734375),excalibur); markers[17] = new GMarker(new GLatLng(-37.96875,-68.203125),excalibur); markers[18] = new GMarker(new GLatLng(33.92578125,-4.921875),excalibur); markers[19] = new GMarker(new GLatLng(20.126953125,-130.60546875),excalibur); markers[20] = new GMarker(new GLatLng(16.083984375,-73.828125),excalibur); markers[21] = new GMarker(new GLatLng(23.115234375,1.58203125),excalibur); markers[22] = new GMarker(new GLatLng(-14.94140625,72.7734375),excalibur); markers[23] = new GMarker(new GLatLng(-35.244140625,9.31640625),excalibur); markers[24] = new GMarker(new GLatLng(5.44921875,-119.70703125),excalibur); markers[25] = new GMarker(new GLatLng(-16.083984375,-87.1875),excalibur); markers[26] = new GMarker(new GLatLng(39.90234375,70.3125),excalibur); markers[27] = new GMarker(new GLatLng(-7.470703125,-14.0625),excalibur); markers[28] = new GMarker(new GLatLng(-5.537109375,89.296875),excalibur); markers[29] = new GMarker(new GLatLng(36.474609375,-55.01953125),excalibur); markers[30] = new GMarker(new GLatLng(6.416015625,-55.01953125),excalibur); markers[31] = new GMarker(new GLatLng(-7.20703125,-114.609375),excalibur); markers[32] = new GMarker(new GLatLng(-48.955078125,44.296875),excalibur); markers[33] = new GMarker(new GLatLng(43.330078125,-21.26953125),excalibur); markers[34] = new GMarker(new GLatLng(45.615234375,-44.82421875),excalibur); markers[35] = new GMarker(new GLatLng(-19.423828125,0.17578125),excalibur); markers[36] = new GMarker(new GLatLng(15.8203125,115.83984375),excalibur); markers[37] = new GMarker(new GLatLng(22.32421875,-99.66796875),excalibur); markers[38] = new GMarker(new GLatLng(10.634765625,-26.71875),excalibur); markers[39] = new GMarker(new GLatLng(25.13671875,88.59375),excalibur); markers[40] = new GMarker(new GLatLng(-30.9375,-25.13671875),excalibur); markers[41] = new GMarker(new GLatLng(-4.39453125,11.77734375),excalibur); //alert(markers.length); for (var i = 0; i < markers.length ; i++ ) { map.addOverlay(markers[i]); } $j("#locationName").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); $j("#locationNameShadow").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); singles = []; singlesIDs = []; clickListeners = []; singles[0] = "araguay"; singlesIDs[0] = "080"; singles[1] = "bariaushill"; singlesIDs[1] = "084"; singles[2] = "bariausvalley"; singlesIDs[2] = "087"; singles[3] = "bed"; singlesIDs[3] = "082"; singles[4] = "berveniacity"; singlesIDs[4] = "044"; singles[5] = "berveniavolcano"; singlesIDs[5] = "075"; singles[6] = "doguola"; singlesIDs[6] = "086"; singles[7] = "doldobar"; singlesIDs[7] = "071"; singles[8] = "finath"; singlesIDs[8] = "088"; singles[9] = "germinas"; singlesIDs[9] = "090"; singles[10] = "golgorand"; singlesIDs[10] = "063"; singles[11] = "grog"; singlesIDs[11] = "081"; singles[12] = "lenaliaplateau"; singlesIDs[12] = "077"; singles[13] = "mandalia"; singlesIDs[13] = "085"; singles[14] = "nelveska"; singlesIDs[14] = "070"; singles[15] = "poeskas"; singlesIDs[15] = "089"; singles[16] = "sweegy"; singlesIDs[16] = "074"; singles[17] = "thievesfort"; singlesIDs[17] = "091"; singles[18] = "yuguo"; singlesIDs[18] = "079"; singles[19] = "zeakden"; singlesIDs[19] = "049"; singles[20] = "zigolis"; singlesIDs[20] = "078"; singles[21] = "zirekile"; singlesIDs[21] = "083"; singlesJoin = "|" + singles.join("|") + "|"; $j(markers).each(function(i,marker){ GEvent.addListener(marker, "mouseover", function(){ displayPoint(marker, i); }); //alert(singlesJoin.indexOf("|"+locations[i]+"|")); //alert(locations[i]); if (singlesJoin.indexOf("|"+locationsDiv[i]+"|") == -1) { clickListeners[i] = GEvent.addListener(marker, "click", function(){ show(i); }); } else { $j(singles).each(function(l,single) { if (single == locationsDiv[i]) { clickListeners[i] = GEvent.addListener(marker, "click", function(){ location.href='http://www.cavesofnarshe.com/fft/maps/mapsingle.php?mapid='+singlesIDs[l]; }); } } ); } GEvent.addListener(marker, "mouseout", function(){ hidePoint() }); }); function displayPoint(marker, i){ var markerOffset = map.fromLatLngToDivPixel(marker.getPoint()); $j("#locationName").html(locations[i]); $j("#locationNameShadow").html(locations[i]); $j("#locationName").show().css({ top:markerOffset.y, left:markerOffset.x }); $j("#locationNameShadow").show().css({ top:markerOffset.y+2, left:markerOffset.x+2 }); } function hidePoint(){ $j("#locationName").hide(); $j("#locationNameShadow").hide(); } } } locations = []; locationsDiv = []; locations[0] = "Araguay Woods"; locationsDiv[0] = "araguay"; locations[1] = "Bariaus Hill"; locationsDiv[1] = "bariaushill"; locations[2] = "Bariaus Valley"; locationsDiv[2] = "bariausvalley"; locations[3] = "Bed Desert"; locationsDiv[3] = "bed"; locations[4] = "Bervenia Free City"; locationsDiv[4] = "berveniacity"; locations[5] = "Bervenia Volcano"; locationsDiv[5] = "berveniavolcano"; locations[6] = "Bethla Garrison"; locationsDiv[6] = "bethla"; locations[7] = "Deep Dungeon"; locationsDiv[7] = "deepdungeon"; locations[8] = "Doguola Pass"; locationsDiv[8] = "doguola"; locations[9] = "Doldobar Swamp"; locationsDiv[9] = "doldobar"; locations[10] = "Dorter Trade City"; locationsDiv[10] = "dorter"; locations[11] = "Finath River"; locationsDiv[11] = "finath"; locations[12] = "Fovoham Plains"; locationsDiv[12] = "fovoham"; locations[13] = "Gariland Magic City"; locationsDiv[13] = "gariland"; locations[14] = "Germinas Peak"; locationsDiv[14] = "germinas"; locations[15] = "Goland Coal City"; locationsDiv[15] = "goland"; locations[16] = "Golgorand Execution Site"; locationsDiv[16] = "golgorand"; locations[17] = "Goug Machine City"; locationsDiv[17] = "goug"; locations[18] = "Grog Hill"; locationsDiv[18] = "grog"; locations[19] = "Igros Castle"; locationsDiv[19] = "igros"; locations[20] = "Lenalia Plateau"; locationsDiv[20] = "lenaliaplateau"; locations[21] = "Lesalia Imperial Capital"; locationsDiv[21] = "lesaliaimperial"; locations[22] = "Limberry Castle"; locationsDiv[22] = "limberry"; locations[23] = "Lionel Castle"; locationsDiv[23] = "lionel"; locations[24] = "Mandalia Plains"; locationsDiv[24] = "mandalia"; locations[25] = "St. Murond Temple"; locationsDiv[25] = "murond"; locations[26] = "Nelveska Temple"; locationsDiv[26] = "nelveska"; locations[27] = "Orbonne Monastery"; locationsDiv[27] = "orbonne"; locations[28] = "Poeskas Lake"; locationsDiv[28] = "poeskas"; locations[29] = "Riovanes Castle"; locationsDiv[29] = "riovanes"; locations[30] = "Sweegy Woods"; locationsDiv[30] = "sweegy"; locations[31] = "Thieves' Fort"; locationsDiv[31] = "thievesfort"; locations[32] = "Warjilis Trade City"; locationsDiv[32] = "warjilis"; locations[33] = "Yardow Fort City"; locationsDiv[33] = "yardow"; locations[34] = "Yuguo Woods"; locationsDiv[34] = "yuguo"; locations[35] = "Zaland Fort City"; locationsDiv[35] = "zaland"; locations[36] = "Zarghidas Trade City"; locationsDiv[36] = "zarghidas"; locations[37] = "Fort Zeakden"; locationsDiv[37] = "zeakden"; locations[38] = "Zeklaus Desert"; locationsDiv[38] = "zeklaus"; locations[39] = "Zeltennia Castle"; locationsDiv[39] = "zeltennia"; locations[40] = "Zigolis Swamp"; locationsDiv[40] = "zigolis"; locations[41] = "Zirekile Falls"; locationsDiv[41] = "zirekile"; locations[42] = "Other Maps"; locationsDiv[42] = "other"; var last = null; function show(id) { var itm = "#"+locationsDiv[id]; var itm = $j(itm); if (!itm) { // do nothing } else { $j(itm).show(); if (last && last != itm) { $j(last).hide(); } last = itm; } } function parseUrl() { if (document.URL) { var urlarray = document.URL.split("#"); if (urlarray[1]) { var position = urlarray[1]; show(position); location.hash = position; } } } /* global scoped var to use in the show maps function below */ mapdivs = "hidden"; function mapToggler() { dumpListeners(); createListeners(mapdivs); adjustFloat(mapdivs); displayMapDivs(mapdivs); if (mapdivs == "hidden") { mapdivs = "visible"; } else { mapdivs = "hidden"; } } function dumpListeners(){ $j(clickListeners).each(function() { GEvent.removeListener(this); }); } function createListeners(status) { if (status=="hidden") { //we are making the divs all visible, so we set the listeners to be links to hashes. $j(markers).each(function(i,marker){ clickListeners[i] = GEvent.addListener(marker, "click", function(){ var primaryURL = document.URL.split("#"); window.location = primaryURL[0] + "#" + locationsDiv[i] }); }); } else { //we are reverting back to the standard GMap click actions. $j(markers).each(function(i,marker){ if (singlesJoin.indexOf("|"+locationsDiv[i]+"|") == -1) { clickListeners[i] = GEvent.addListener(marker, "click", function(){ show(i); }); } else { $j(singles).each(function(l,single) { if (single == locationsDiv[i]) { clickListeners[i] = GEvent.addListener(marker, "click", function(){ location.href='http://www.cavesofnarshe.com/fft/maps/mapsingle.php?mapid='+singlesIDs[l]; }); } } ); } }); } } function adjustFloat(status) { if (status=="hidden") { //we are making the divs all visible, so we need to break the float. $j("#googleMap").css("float","none"); } else { $j("#googleMap").css("float","left"); } } function displayMapDivs(status) { if (status=="hidden") { //we are making the divs all visible, so we need to... make the divs all visible. idiot. $j(".metalocation").hide(); $j(".metalocation").show(); } else { $j(".metalocation").hide(); } }