From: Lukas J. <luk...@de...> - 2010-11-29 08:40:35
|
Have you checked with firebug if any request are actually sent? Probably they aren't as you get a JS error and you don't see anything in the log at the server. By just "dry reading" your code I don't see anything that pops out. You do get a "String cannot be cast to JSObject" exception and the only row I can guess cases this is: options.setLayers(getWMSMapLayers().toArray(new WMS[0])); What does getWMSMapLayers() return? Which toArray method is called?.... /Lukas Från: man...@go... [mailto:man...@go...] För Jon Britton Skickat: den 26 november 2010 18:49 Till: Lukas Johansson Kopia: gwt-openlayers-users Ämne: Re: [Gwt-openlayers-users] MapClickListener support Hi Lukas, I've added a WMSGetFeatureInfo control to my map, but when I make a request (by clicking on the map) the map freezes. I've checked by WMS server logs and it did receive a GetFeatureInfo request and seems to have returned a result. I was originally testing in Google Chrome, but I tried Firefox and get the same problem - however I also get a JavaScript exception: Uncaught JavaScript exception [uncaught exception: java.lang.ClassCastException: java.lang.String cannot be cast to org.gwtopenmaps.openlayers.client.util.JSObject] in , line 0 Any idea what could be causing this? My code is shown below. Thanks, Jon public void resetWMSSelectControl() { if (wmsSelectControl != null) SmartWPS.getSmartWPS().getMap().removeControl(wmsSelectControl); WMSGetFeatureInfoOptions options = new WMSGetFeatureInfoOptions(); options.setLayers(getWMSMapLayers().toArray(new WMS[0])); options.setDrillDown(true); options.setQueryVisible(true); options.setInfoFormat("application/vnd.ogc.gml"); wmsSelectControl = new WMSGetFeatureInfo(options); wmsSelectControl.addGetFeatureListener(new GetFeatureInfoListener() { @Override public void onGetFeatureInfo( org.gwtopenmaps.openlayers.client.event.GetFeatureInfoListener.GetFeatureInfoEvent eventObject) { VectorFeature[] features = eventObject.getFeatures(); System.out.println("FeatureInfo: " + eventObject.getText()); } }); SmartWPS.getSmartWPS().getMap().addControl(wmsSelectControl); wmsSelectControl.activate(); } On 24 November 2010 16:01, Lukas Johansson <luk...@de...> wrote: I've commited a version that make the control a more complete and which uses the drilldown parameter introduced in OL 2.9[1] which can be used to access multiple servers. In october we realized that my patch hadn't been commited so this was taken care of, however I do not think that its in the current stable build. Instead you need to checkout your own version. [1] http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Control/WMSGetFeatureInfo-js.html#OpenLayers.Control.WMSGetFeatureInfo.drillDown You add the controller to the map, if you do not use drilldown only to top layer is queried. Most settings are set in WmsGetFeatureInfoOptions and not on the control itself. Usage is something along this path (copied from our working code, but you get the idea): WMSGetFeatureInfoOptions options = new WMSGetFeatureInfoOptions(); options.setLayers(arrayOfLayersToQuery)); //allows you to tell what layers that should be queried options.setDrillDown(true); options.setQueryVisible(true); options.setInfoFormat("application/vnd.ogc.gml"); //return result as gml wmsSelectControl = new WMSGetFeatureInfo(options); wmsSelectControl.addGetFeatureListener(new GetFeatureInfoListener(){ public void onGetFeatureInfo(GetFeatureInfoEvent eventObject) { VectorFeature[] features = eventObject.getFeatures(); String html = "foo"; FrameCloud popup = new FramedCloud("MapFeaturePopup", features[0].getCenterLonLat(), new Size(300, 400), html); } } map.addControl(wmsSelectControl); /Lukas Från: man...@go... [mailto:man...@go...] För Jon Britton Skickat: den 24 november 2010 16:42 Till: Lukas Johansson Kopia: gwt-openlayers-users Ämne: Re: [Gwt-openlayers-users] MapClickListener support Hi Lukas, You haven't misunderstood, I wasn't aware there was a map control for this. My client application is for displaying many WMS layers, possibly from different servers. The user can add/remove WMS layers as they see fit by using their own WMS URLs. What I want to do is display the feature info for every layer currently visible on my map, but I'm struggling to figure out how WMSGetFeatureInfo can be used for this as each control corresponds to only one WMS URL. Would I need to make a new control for each map layer? Another problem is that the GWT-Openlayers WMGetFeatureInfo control seems to be incomplete as I can't access many of it's properties directly (such as url, title, layers...). Thanks, Jon On 24 November 2010 15:37, Lukas Johansson <luk...@de...> wrote: You want the x/y of the mouseclick in order to construct a WMSGetFeautureInfo? Why not use the existing WMSGetFeatureInfo control to begin with? This will handle the events, the request to the server and you can get it to produce a parsable result in GML from witch you can create features. Or have I misunderstood your usecase? /Lukas Från: Jon Britton [mailto:jon...@go...] Skickat: den 24 november 2010 15:20 Till: gwt-openlayers-users Ämne: [Gwt-openlayers-users] MapClickListener support Hi I'm trying to register a MapClickListener so that I can generate a GetFeatureInfo request using the mouse x and y coordinates. Here is what I've got so far: mw.getMap().getListeners().add(new MapClickListener() { @Override public void onClick(MapClickEvent e) { SC.say("Map click at " + e.getLonLat()); } }); However, getListeners() isn't supported as far as I can tell (I get an UnsupportedOperationException on the first line above). Are there any plans to implement this soon? Alternatively, is there any other way to access the map coordinates of the mouse cursor? Thanks, Jon ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Gwt-openlayers-users mailing list Gwt...@li... https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Gwt-openlayers-users mailing list Gwt...@li... https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users |