Yeah such things should be added to the gmap2 js namespace as functions or such.. should be possible and more clean..
2009/9/16 Martin Funk <[email protected]>: > 2009/9/16 Martin Funk <[email protected]> > >> Hi Doug, >> >> the change of getJSconstructor() from protected to public is fine by me. >> Go ahead an commit that change. >> > > argh... I withdraw and claim the opposite. > or at least rethink it really hard. > If the map you are reffering to already has a JavaSript-counterpart-instance > on the client your ar most likely better of doing al that in a JavaScript on > the client side. > > mf > > > >> >> The client code you posted, I haven't analyzed in depth, but seeing all >> that JavaScript genereated on the Server using so many String literals would >> make me start to think if that code could somehow be moved into a custom >> JavaScript file. >> So instead of shoving all that JavaScript code from the server to the >> client things could me reduced to calling a custom JavaScript function. It >> might be mind bending, but I think its always worth a thought. >> >> mf >> >> 2009/9/16 Doug Leeper <[email protected]> >> >> I recently moved from 1.3.6 to 1.4.1 and came across a compile error. I >>> believe I had a local copy of GMap2 (1.3.x) and made modifications to make >>> the following work. >>> >>> Now I would like to propose a change but not sure who I need to talk. >>> Specifically, I would like to request to change GOverlay.getJSConstructor() >>> from protected to public (and all subsequent derived classes) >>> >>> I am need to send javascript back to the browser which basically rebounds >>> the a GMap2...the following is my code snippet: >>> >>> <raw> >>> private String getJSRebound() { >>> StringBuffer buf = new StringBuffer(); >>> buf.append("var bounds = new GLatLngBounds();\n"); >>> buf.append("var map = " + map.getJSinvoke("map")); >>> buf.append("bounds.extend( map.getCenter() ); \n"); >>> >>> int idx = 0; >>> >>> for (GOverlay overlay : map.getOverlays()) { >>> if (overlay instanceof GMarker) { >>> GMarker marker = (GMarker) overlay; >>> GLatLng point = marker.getLatLng(); >>> buf.append("bounds.extend( " + point.getJSconstructor() >>> + " );\n"); >>> } >>> >>> if (overlay instanceof GGeoXml) { >>> GGeoXml xml = (GGeoXml) overlay; >>> >>> String var = "xml" + idx++; >>> >>> // this is broken with 1.4.1 >>> // getJSconstructor has been made protected >>> >>> buf.append("var " + var + " = " + xml.getJSconstructor() >>> + "; \n"); >>> >>> buf.append("GEvent.addListener(" + var >>> + ", 'load', function(){ \n"); >>> buf.append(" bounds.extend( " + var >>> + ".getDefaultBounds().getSouthWest() ); \n"); >>> buf.append(" bounds.extend( " + var >>> + ".getDefaultBounds().getNorthEast() ); \n"); >>> buf.append("map.setZoom( map.getBoundsZoomLevel(bounds) >>> );\n"); >>> buf.append("}); \n"); >>> } >>> } >>> >>> if (idx == 0) { >>> GLatLng point = new GLatLng(location.getCentralLatitude(), >>> location >>> .getCentralLongitude(), false); >>> buf.append("bounds.extend( " + point.getJSconstructor() + " >>> );\n"); >>> buf >>> .append("map.setZoom( >>> Math.min(map.getBoundsZoomLevel(bounds),8) );\n"); >>> } else { >>> buf.append("map.setZoom( map.getBoundsZoomLevel(bounds) );\n"); >>> } >>> buf.append("map.setCenter( bounds.getCenter() );\n"); >>> return buf.toString(); >>> } >>> </raw> >>> >>> This method is called in my constructor: >>> >>> <raw> >>> map.add(new HeaderContributor(new IHeaderContributor() { >>> private static final long serialVersionUID = 1L; >>> >>> public void renderHead(IHeaderResponse response) { >>> response.renderOnDomReadyJavascript(getJSRebound()); >>> } >>> })); >>> </raw> >>> >>> >>> Without the ability to generated the JS object and keep a reference, I >>> don't believe I can accomplish what I need to do...rebound the map within >>> the points I have stored. If someone has a better idea, I am all ears. If >>> not, the accessibliity change would greatly be appreciated. >>> >>> Thanks >>> - Doug >> >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
