currentMouseHOffset = "" ; currentMouseVOffset = "" ; initTrackMouse() ; function initTrackMouse() { var isNS4=document.layers?true:false; var isIE=document.all?true:false; var isIE6=isIE&&document.getElementById?true:false; var isIE4=isIE&&!isIE6?true:false; var isNS6=!isIE6&&document.getElementById?true:false; var isNS=isNS4||isNS6; if(isNS4) { document.captureEvents(Event.MOUSEMOVE); document.onmousemove=showMouseLocation; } else if(isNS6) { document.addEventListener("mousemove", showMouseLocation, true); } else if(isIE) { document.onmousemove=showMouseLocation; } } function showMouseLocation(e) { //var isNS4=document.layers?true:false; var isIE=document.all?true:false; var isIE6=isIE&&document.getElementById?true:false; var isIE4=isIE&&!isIE6?true:false; //var isNS6=!isIE6&&document.getElementById?true:false; //var isNS=isNS4||isNS6; if (isIE4) { return true ; } if (document.all) { var mouseHOffset = event.clientX ; var mouseVOffset = event.clientY ; } else { var mouseHOffset = e.pageX ; var mouseVOffset = e.pageY ; } var theHScroll = 0; var theVScroll = 0; if (window.pageYOffset) { theHScroll = window.pageXOffset; theVScroll = window.pageYOffset; } else if (window.document.documentElement && window.document.documentElement.scrollTop) { theHScroll = window.document.body.scrollLeft; theVScroll = window.document.body.scrollTop; } else if (window.document.body) { theHScroll = window.document.body.scrollLeft; theVScroll = window.document.body.scrollTop; } if (browserType == "Internet Explorer") { mouseHOffset += theHScroll ; mouseVOffset += theVScroll ; } if (browserType == "Mozilla") { mouseVOffset -= 1 ; mouseHOffset -= 1 ; } else if (browserType == "Internet Explorer" && platformType == "Windows") { mouseHOffset -= 2 ; mouseVOffset -= 2 ; } currentMouseHOffset = mouseHOffset ; currentMouseVOffset = mouseVOffset ; if (document.getElementById('mapCanvas') && document.getElementById('latitude') ) { showMapLocation(mouseHOffset,mouseVOffset) ; } } function showMapLocation(mouseHOffset,mouseVOffset) { // check if map has actually been loaded, else return if (typeof map == 'undefined') { return false ; } if (document.getElementById('mapCanvas')) { mapLeft = removePx(document.getElementById('mapCanvas').style.left?document.getElementById('mapCanvas').style.left:'0px'); mapTop = removePx(document.getElementById('mapCanvas').style.top?document.getElementById('mapCanvas').style.top:'0px'); mapWidth = removePx(document.getElementById('mapCanvas').style.width); mapHeight = removePx(document.getElementById('mapCanvas').style.height) ; if (browserType == "Mozilla" ) { mapLeft -= 1 ; mapTop -= 1 ; } mapRight = mapLeft + mapWidth - 1 ; mapBottom = mapTop + mapHeight - 1 ; } selectionHorizontalOffset = mouseHOffset ; selectionVerticalOffset = mouseVOffset ; if ( mouseHOffset < mapLeft || mouseHOffset > mapRight || mouseVOffset < mapTop || mouseVOffset > mapBottom ) { document.getElementById('longitude').innerHTML = "" ; document.getElementById('latitude').innerHTML = "" ; } else { mapMouseHOffset = mouseHOffset - mapLeft ; mapMouseVOffset = mouseVOffset - mapTop ; var coordinatesInDegrees = map.fromContainerPixelToLatLng(new GPoint(mapMouseHOffset,mapMouseVOffset)) ; if (map && map.getZoom() > 12) { var showSeconds = true ; } else { var showSeconds = false ; } var longitude = convertToDegreesMinutesAndSeconds(coordinatesInDegrees.x,"longitude",showSeconds) ; var latitude = convertToDegreesMinutesAndSeconds(coordinatesInDegrees.y,"latitude",showSeconds) ; var latitude = "

" + latitude + "

" var longitude = "

" + longitude + "

" ; if (document.getElementById('latitude').innerHTML != latitude) { document.getElementById('latitude').innerHTML = latitude ; } if (document.getElementById('longitude').innerHTML != longitude) { document.getElementById('longitude').innerHTML = longitude ; } if (selectedMapTool && mousedownmarker && selectedMapTool == "maptoolrectangle") { updateRectangleSelection(coordinatesInDegrees) ; } } } function convertToDegreesMinutesAndSeconds(value,latitudeOrLongitude,showSeconds) { var degrees = "0°" ; var minutes = "" ; var direction = "" ; if (value > 0) { if (latitudeOrLongitude == "latitude") { var direction = " N" ; } else if (latitudeOrLongitude == "longitude") { var direction = " E" ; } } else if (value < 0) { if (latitudeOrLongitude == "latitude") { var direction = " S" ; } else if (latitudeOrLongitude == "longitude") { var direction = " W" ; } } value = Math.abs(value) ; degrees = Math.floor(value) ; minutes = value - degrees ; minutes = Math.floor(minutes*60) ; seconds = ((value - degrees)*60 )- minutes ; seconds = Math.floor(seconds*60) ; if (minutes > 0) { if (minutes < 10) { minutes = "0" + minutes ; } minutes += "'" ; } else { minutes = "" ; } if (seconds > 0) { if (seconds < 10) { seconds = "0" + seconds ; } seconds += "\"" ; } else { seconds = "" ; } if (degrees == 0 && minutes == "") { direction = "" ; } var coordinatesString = degrees + "°" + minutes ; if (showSeconds == true) { coordinatesString += seconds ; } coordinatesString += direction ; return coordinatesString ; } function removePx(pixelString) { if (pixelString.indexOf("px") != -1) { pixelString = pixelString.substr(0,pixelString.indexOf("px")) ; } return parseInt(pixelString) ; } function showStoredSelection(thisPolygon) { var coordinatePairs = thisPolygon.split(",") ; if (browserType != "Internet Explorer") { var points = new Array() ; for (var i = 0 ; i < coordinatePairs.length; i ++) { var theseCoordinates = coordinatePairs[i].split(" ") ; theseCoordinates = new GLatLng(theseCoordinates[1],theseCoordinates[0]) ; points.push(theseCoordinates) ; } map.addOverlay(new GPolyline(points, "#FFFF00", 2, 1)); } for (var i = 0 ; i < coordinatePairs.length; i ++) { var theseCoordinates = coordinatePairs[i].split(" ") ; var thisLatitude = parseFloat(theseCoordinates[1]) ; var thisLongitude = parseFloat(theseCoordinates[0]) ; if (i == 0) { var minimumLatitude = thisLatitude ; var maximumLatitude = thisLatitude ; var minimumLongitude = thisLongitude ; var maximumLongitude = thisLongitude ; continue ; } if (thisLatitude > maximumLatitude) { maximumLatitude = thisLatitude ; } else if (thisLatitude < minimumLatitude) { minimumLatitude = thisLatitude ; } if (thisLongitude > maximumLongitude) { maximumLongitude = thisLongitude ; } else if (thisLongitude < minimumLongitude) { minimumLongitude = thisLongitude ; } } var centerLatitude = ((minimumLatitude + maximumLatitude) / 2); var centerLongitude = ((minimumLongitude + maximumLongitude) / 2); var bounds = new GLatLngBounds(); var corner1 = new GLatLng(minimumLatitude,minimumLongitude); bounds.extend(corner1); var corner2 = new GLatLng(maximumLatitude,maximumLongitude); bounds.extend(corner2); map.setZoom(map.getBoundsZoomLevel(bounds)); var point = new GLatLng(centerLatitude,centerLongitude) ; map.setCenter(point); } // Create a base icon for all of our markers that specifies the // shadow, icon dimensions, etc. var baseIcon = new GIcon(); baseIcon.shadow = "images/mapicons/mapicon_reds.png"; baseIcon.iconSize = new GSize(32, 32); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); baseIcon.infoShadowAnchor = new GPoint(18, 25); // Creates a marker whose info window displays the letter corresponding // to the given index. function createMarker(point, inf) { // Create a lettered icon for this point using our icon class var markerIcon = new GIcon(baseIcon); markerIcon.image = "images/mapicons/mapicon_red.png"; // Set up our GMarkerOptions object markerOptions = { icon:markerIcon }; var marker = new GMarker(point, markerOptions); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("" + inf.name + "
" + (inf.loc=="" ? "" : inf.loc + "
") + inf.geo); }); return marker; } function addMarker(str,inf) { str = str.split(','); var latlng = new GLatLng(str[1],str[0]); map.addOverlay(createMarker(latlng, inf)); } function dec2deg(val) { var dummy = val.split("."); if (dummy[1]!="") { var x = (val-dummy[0])*60; } else { var x = 0; } return dummy[0]+"°"+Math.round(x,2)+"'"; } function mapMarkerInfo(a,b,c,d,e) { this.name = a; this.loc = b; this.date = c; this.source = d; var dummy = e.split(","); f = (dummy[0].substr(0,1)=="-" ? dec2deg(dummy[0].substr(1)) + "W" : dec2deg(dummy[0]) + "E")+" "+ (dummy[1].substr(0,1)=="-" ? dec2deg(dummy[1].substr(1)) + "S" : dec2deg(dummy[0]) + "N"); this.geo = f; }