From: <cph...@us...> - 2006-05-01 03:12:12
|
Revision: 44 Author: cphillip Date: 2006-04-30 20:12:06 -0700 (Sun, 30 Apr 2006) ViewCVS: http://svn.sourceforge.net/wnmap/?rev=44&view=rev Log Message: ----------- Update some basics in the port and ensure we center correctly. * web/js/NodeMarker.js (NodeMarker): Just housekeeping to ensure we call the correct constructor. * web/js/nodemap.js (createMap): Ensure we call setCenter() to correctly initialize the map. (instanceOf): Added this function to assist debugging. Modified Paths: -------------- branches/gmap2-port/web/js/NodeMarker.js branches/gmap2-port/web/js/nodemap.js Modified: branches/gmap2-port/web/js/NodeMarker.js =================================================================== --- branches/gmap2-port/web/js/NodeMarker.js 2006-05-01 01:09:56 UTC (rev 43) +++ branches/gmap2-port/web/js/NodeMarker.js 2006-05-01 03:12:06 UTC (rev 44) @@ -22,7 +22,7 @@ icon.iconAnchor = new GPoint(9, 34); icon.infoWindowAnchor = new GPoint(20, 1); - GMarker.call (this, point, icon); + NodeMarker.baseConstructor.call (this, point, icon); break; case 'potential': this.statePretty = "Potential Node"; @@ -32,12 +32,12 @@ icon.iconSize = new GSize(20, 34); icon.iconAnchor = new GPoint(9, 34); icon.infoWindowAnchor = new GPoint(20, 1); - GMarker.call (this, point, icon); + NodeMarker.baseConstructor.call (this, point, icon); break; case 'marker': this.statePretty = "Marker"; - GMarker.call (this, point); + NodeMarker.baseConstructor.call (this, point); this.step = 1; break; default: @@ -45,7 +45,6 @@ return; break; } - this.getHtml = function () { var html = ""; Modified: branches/gmap2-port/web/js/nodemap.js =================================================================== --- branches/gmap2-port/web/js/nodemap.js 2006-05-01 01:09:56 UTC (rev 43) +++ branches/gmap2-port/web/js/nodemap.js 2006-05-01 03:12:06 UTC (rev 44) @@ -20,8 +20,7 @@ map = new GMap2(document.getElementById("mapColumn")); map.addControl(new GLargeMapControl()); map.addControl (new GMapTypeControl()); - // FIXME - // map.centerAndZoom(new GPoint(WNMAP_MAP_START_LON, WNMAP_MAP_START_LAT), parseInt(WNMAP_MAP_START_ZOOM)); + map.setCenter(new GLatLng(WNMAP_MAP_START_LAT, WNMAP_MAP_START_LON), parseInt(WNMAP_MAP_START_ZOOM)); map.setMapType (G_NORMAL_MAP); map.addControl(new GScaleControl()); // GKeyboardHandler(map); // with this on, "this.lg is not a function" @@ -42,8 +41,6 @@ request.onreadystatechange = function () { if (request.readyState == 4) { - var pointTable = []; - var xmlDoc = request.responseXML; // Add Nodes @@ -136,9 +133,7 @@ // Add Markers // inside here: a.initialize is not a function for (var key in markers) { -//alert("key = " + key); var node = markers[key]; -//alert("node = " + node); if (node.state == 'active' && document.getElementById ("showActive").checked == false) { node.visible = false; @@ -283,3 +278,12 @@ } return null; } + +function instanceOf(object, constructorFunction) { + while (object != null) { + if (object == constructorFunction.prototype) + {return true} + object = object.__proto__; + } + return false; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cph...@us...> - 2006-05-20 23:45:21
|
Revision: 49 Author: cphillip Date: 2006-05-20 16:45:14 -0700 (Sat, 20 May 2006) ViewCVS: http://svn.sourceforge.net/wnmap/?rev=49&view=rev Log Message: ----------- Fix tooltips in GMap2 port. * web/js/NodeMarker.js (main): Chase destroyTooltip rename to hideTooltip. Store tooltip HTML in NodeMarker object. (zoomTo): Chase destroyTooltip rename to hideTooltip. (showTooltip): Rewrite to support GMap2. (destroyTooltip/hideTooltip): Rename to accurately describe new effect. (removeMarker): Chase destroyTooltip rename to hideTooltip. * web/js/nodemap.js (populateMap): Chase destroyTooltip rename to hideTooltip. Modified Paths: -------------- branches/gmap2-port/web/js/NodeMarker.js branches/gmap2-port/web/js/nodemap.js Modified: branches/gmap2-port/web/js/NodeMarker.js =================================================================== --- branches/gmap2-port/web/js/NodeMarker.js 2006-05-12 00:39:01 UTC (rev 48) +++ branches/gmap2-port/web/js/NodeMarker.js 2006-05-20 23:45:14 UTC (rev 49) @@ -9,6 +9,7 @@ this.state = state; this.visible = true; this.streetAddress = "n/a"; + this.tooltip = this.name; var point = new GLatLng (lat, lng); @@ -32,6 +33,7 @@ icon.iconSize = new GSize(20, 34); icon.iconAnchor = new GPoint(9, 34); icon.infoWindowAnchor = new GPoint(20, 1); + NodeMarker.baseConstructor.call (this, point, icon); break; case 'marker': @@ -206,48 +208,53 @@ } this.zoomTo = function () { - this.destroyTooltip (); + this.hideTooltip (); map.setCenter (this.getPoint(), 17); this.openInfoWindowHtml (this.getHtml()); } + // In GMap2, the maps API changed sufficiently to break the original tooltip code contained here. + // As a part of the port to GMap2, I'd like to thank toEat.com and Robert Aspinall for doing the + // heavy lifting in that code. It showed the way for how to re-implement tooltips in GMap2. this.showTooltip = function () { - if (!this.tooltip) { - var tooltip = document.createElement ('div'); - tooltip.innerHTML = this.name; + if (this.tooltip) { + if (!this.tooltipObject) { + this.tooltipObject = document.createElement ('div'); + this.tooltipObject.innerHTML = this.name; - var opacity = .70; - className ="tooltip"; - tooltip.className ="tooltip"; - tooltip.style.position = 'relative'; - tooltip.style.background = 'white'; - tooltip.style.border = '1px solid black'; - tooltip.style.padding = '2px'; - tooltip.style.zIndex = 50000; - tooltip.style.filter = "alpha(opacity=" + opacity + ")"; - tooltip.style.opacity = opacity; + var opacity = .70; + this.tooltipObject.className ="tooltip"; + this.tooltipObject.style.position = 'relative'; + this.tooltipObject.style.background = 'white'; + this.tooltipObject.style.border = '1px solid black'; + this.tooltipObject.style.padding = '2px'; + this.tooltipObject.style.zIndex = 50000; + this.tooltipObject.style.filter = "alpha(opacity=" + opacity + ")"; + this.tooltipObject.style.opacity = opacity; - var b = map.spec.getBitmapCoordinate (this.getPoint().lat(), this.getPoint().lng(), map.getZoom()); - var c = map.getDivCoordinate (b.x, b.y); - tooltip.style.left = c.x + (this.icon.iconAnchor.x + 5) + "px"; - tooltip.style.top = c.y - (this.icon.iconAnchor.y) + "px"; - tooltip.style.display = "block"; - - map.div.appendChild (tooltip); + map.getPane(G_MAP_MARKER_PANE).appendChild(this.tooltipObject); + } - this.tooltip = tooltip; + var c = map.fromLatLngToDivPixel(new GLatLng(this.getPoint().lat(), this.getPoint().lng())); + + try { + this.tooltipObject.style.top = c.y - ( this.getIcon().iconAnchor.y + 5 ) + "px"; + this.tooltipObject.style.left = c.x + ( this.getIcon().iconSize.width - this.getIcon().iconAnchor.x + 5 ) + "px"; + this.tooltipObject.style.display = "block"; + } catch(e) { + alert(e); + } } } - this.destroyTooltip = function () { - if (this.tooltip) { - map.div.removeChild (this.tooltip); - this.tooltip = null; + this.hideTooltip = function () { + if (this.tooltipObject) { + this.tooltipObject.style.display = "none"; } } this.removeMarker = function () { - this.destroyTooltip (); + this.hideTooltip (); delete markers[this.name]; @@ -256,7 +263,7 @@ GEvent.addListener (this, 'click', this.select); GEvent.addListener (this, 'mouseover', this.showTooltip); - GEvent.addListener (this, 'mouseout', this.destroyTooltip); + GEvent.addListener (this, 'mouseout', this.hideTooltip); } Modified: branches/gmap2-port/web/js/nodemap.js =================================================================== --- branches/gmap2-port/web/js/nodemap.js 2006-05-12 00:39:01 UTC (rev 48) +++ branches/gmap2-port/web/js/nodemap.js 2006-05-20 23:45:14 UTC (rev 49) @@ -147,9 +147,9 @@ // a proper marker overlay? if (node.state == 'active' | node.state == 'potential') { - nodeList.innerHTML += '<li onmouseover="getMarker(\'' + encode64(node.name) + '\').showTooltip();" onmouseout="getMarker(\'' + encode64(node.name) + '\').destroyTooltip();" class="nodeitem-' + node.state + '"><a href="javascript:getMarker(\'' + encode64(node.name) + '\').select();" style="font-weight: bold;">' + node.name + '</a> <a href="javascript:getMarker(\'' + encode64(node.name) + '\').zoomTo();" class="zoomLink">zoom</a></li>'; + nodeList.innerHTML += '<li onmouseover="getMarker(\'' + encode64(node.name) + '\').showTooltip();" onmouseout="getMarker(\'' + encode64(node.name) + '\').hideTooltip();" class="nodeitem-' + node.state + '"><a href="javascript:getMarker(\'' + encode64(node.name) + '\').select();" style="font-weight: bold;">' + node.name + '</a> <a href="javascript:getMarker(\'' + encode64(node.name) + '\').zoomTo();" class="zoomLink">zoom</a></li>'; } else { - markerList.innerHTML += '<li onmouseover="getMarker(\'' + encode64(node.name) + '\').showTooltip();" onmouseout="getMarker(\'' + encode64(node.name) + '\').destroyTooltip();" class="nodeitem-' + node.state + '"><div style="float: right; padding-right:5px;">(<a href="javascript:getMarker(\'' + encode64(node.name) + '\').removeMarker();">x</a>)</div><a href="javascript:getMarker(\'' + encode64(node.name) + '\').select();" style="font-weight: bold;">' + node.name + '</a> <a href="javascript:getMarker(\'' + encode64(node.name) + '\').zoomTo();" class="zoomLink">zoom</a></li>'; + markerList.innerHTML += '<li onmouseover="getMarker(\'' + encode64(node.name) + '\').showTooltip();" onmouseout="getMarker(\'' + encode64(node.name) + '\').hideTooltip();" class="nodeitem-' + node.state + '"><div style="float: right; padding-right:5px;">(<a href="javascript:getMarker(\'' + encode64(node.name) + '\').removeMarker();">x</a>)</div><a href="javascript:getMarker(\'' + encode64(node.name) + '\').select();" style="font-weight: bold;">' + node.name + '</a> <a href="javascript:getMarker(\'' + encode64(node.name) + '\').zoomTo();" class="zoomLink">zoom</a></li>'; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cph...@us...> - 2006-05-20 23:51:06
|
Revision: 50 Author: cphillip Date: 2006-05-20 16:50:57 -0700 (Sat, 20 May 2006) ViewCVS: http://svn.sourceforge.net/wnmap/?rev=50&view=rev Log Message: ----------- Clean up comments. Modified Paths: -------------- branches/gmap2-port/web/js/NodeMarker.js branches/gmap2-port/web/js/nodemap.js Modified: branches/gmap2-port/web/js/NodeMarker.js =================================================================== --- branches/gmap2-port/web/js/NodeMarker.js 2006-05-20 23:45:14 UTC (rev 49) +++ branches/gmap2-port/web/js/NodeMarker.js 2006-05-20 23:50:57 UTC (rev 50) @@ -213,9 +213,11 @@ this.openInfoWindowHtml (this.getHtml()); } - // In GMap2, the maps API changed sufficiently to break the original tooltip code contained here. - // As a part of the port to GMap2, I'd like to thank toEat.com and Robert Aspinall for doing the - // heavy lifting in that code. It showed the way for how to re-implement tooltips in GMap2. + // In GMap2, the maps API changed sufficiently to break the original + // tooltip code contained here. As a part of the port to GMap2, I'd + // like to thank toEat.com and Robert Aspinall for doing the heavy + // lifting in that code. It showed the way for how to re-implement + // tooltips in GMap2. this.showTooltip = function () { if (this.tooltip) { if (!this.tooltipObject) { Modified: branches/gmap2-port/web/js/nodemap.js =================================================================== --- branches/gmap2-port/web/js/nodemap.js 2006-05-20 23:45:14 UTC (rev 49) +++ branches/gmap2-port/web/js/nodemap.js 2006-05-20 23:50:57 UTC (rev 50) @@ -129,7 +129,7 @@ nodeList.innerHTML = ""; markerList.innerHTML = ""; - // Add Markers // inside here: a.initialize is not a function + // Add Markers for (var key in markers) { var node = markers[key]; @@ -143,8 +143,7 @@ node.visible = true; - map.addOverlay (node); // inside here: a.initialize is not a function // is node not - // a proper marker overlay? + map.addOverlay (node); if (node.state == 'active' | node.state == 'potential') { nodeList.innerHTML += '<li onmouseover="getMarker(\'' + encode64(node.name) + '\').showTooltip();" onmouseout="getMarker(\'' + encode64(node.name) + '\').hideTooltip();" class="nodeitem-' + node.state + '"><a href="javascript:getMarker(\'' + encode64(node.name) + '\').select();" style="font-weight: bold;">' + node.name + '</a> <a href="javascript:getMarker(\'' + encode64(node.name) + '\').zoomTo();" class="zoomLink">zoom</a></li>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |