|
From: Cerávolo, R. V.B. <raf...@gm...> - 2010-02-11 13:55:08
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Just after I sent the last mail, I found the solution!<br>
<br>
The problem was that both maps was using the same instance of
MapOptions. When using a new instance of MapOptions (even if they are
identical) for each MapWidget, the problem does not happen any more!<br>
<br>
At least, I hope this mail helps others with this same issue.<br>
<br>
Regards,<br>
Rafael Cerávolo<br>
<br>
On 11/02/2010 11:17, "Cerávolo, Rafael V.B." wrote:
<blockquote cite="mid:4B7...@gm..." type="cite">
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
Hi,<br>
<br>
When showing multiple maps, with Google Maps as the base layer, at same
time, a problem occurs.<br>
<br>
The second map that is added works fine, but the first map, lose all
control over their layers (including the base layer) and over the
navigation controls. When zooming the first map, the zoom actually
occurs on the second map.<br>
Also, the image of the zoom bar in the first map shows the zoom bar of
the second layer.<br>
<br>
Other problem, is the Layer name. I named the google layer of the first
map as "Google 1" and the second as "Google 2". But the "Google 2"
appears in both layer switches.<br>
<br>
I tested this issue with the gwt-openlayers-showcase, to make sure that
is not a issue with my application, and the problem is there as well!<br>
<br>
I don't know if this is a problem just with GWT-OpenLayers or if it
exists in the original OpenLayers JavaScript.<br>
<br>
Does any one had this problem too? And more important, does any one
know how the solution?<br>
<br>
Attached is the screen-shot of the problem.<br>
<br>
And below is the code I'm using. It is just the MapExample.java of the
showcase changed to add two GoogleMaps to the dockpanel.<br>
<br>
Greetings,<br>
Rafael Cerávolo<br>
<br>
------------------------------------------------<br>
<b><tt>package org.gwtopenmaps.demo.openlayers.client.examples;<br>
<br>
import java.util.ArrayList;<br>
<br>
import org.gwtopenmaps.openlayers.client.LonLat;<br>
import org.gwtopenmaps.openlayers.client.Map;<br>
import org.gwtopenmaps.openlayers.client.MapOptions;<br>
import org.gwtopenmaps.openlayers.client.MapWidget;<br>
import org.gwtopenmaps.openlayers.client.control.LayerSwitcher;<br>
import org.gwtopenmaps.openlayers.client.control.MousePosition;<br>
import org.gwtopenmaps.openlayers.client.control.NavToolBar;<br>
import org.gwtopenmaps.openlayers.client.control.PanZoomBar;<br>
import org.gwtopenmaps.openlayers.client.layer.Google;<br>
import org.gwtopenmaps.openlayers.client.layer.Layer;<br>
import org.gwtopenmaps.openlayers.client.layer.TransitionEffect;<br>
import org.gwtopenmaps.openlayers.client.layer.WMS;<br>
import org.gwtopenmaps.openlayers.client.layer.WMSOptions;<br>
import org.gwtopenmaps.openlayers.client.layer.WMSParams;<br>
<br>
import com.google.gwt.user.client.ui.DockPanel;<br>
import com.google.gwt.user.client.ui.Widget;<br>
<br>
public class MapExample extends DockPanel {<br>
<br>
private MapOptions defaultMapOptions;<br>
// private MapWidget mapWidget;<br>
private Map map;<br>
private ArrayList<Widget> widgets = new
ArrayList<Widget>();<br>
<br>
public MapExample() {<br>
this.defaultMapOptions = new MapOptions();<br>
// In OL, the map gets PanZoom, Navigation, ArgParser, and
Attribution<br>
// Controls<br>
// by default. Do removeDefaultControls to remove these.<br>
this.defaultMapOptions.removeDefaultControls();<br>
this.defaultMapOptions.setNumZoomLevels(16);<br>
this.defaultMapOptions.setProjection("EPSG:4326");<br>
initMapWidget(this.defaultMapOptions);<br>
}<br>
<br>
public MapExample(MapOptions options) {<br>
initMapWidget(options);<br>
}<br>
<br>
private void initMapWidget(MapOptions options) {<br>
MapWidget mapWidget = new MapWidget("350px", "350px",
defaultMapOptions);<br>
this.map = mapWidget.getMap();<br>
add(mapWidget, DockPanel.CENTER);<br>
<br>
MapWidget firstMap = new MapWidget("350px", "350px",
defaultMapOptions);<br>
add(firstMap, DockPanel.EAST);<br>
firstMap.getMap().addLayers(new Layer[] { new Google("Google 1") });<br>
firstMap.getMap().addControl(new PanZoomBar());<br>
firstMap.getMap().addControl(new NavToolBar());<br>
firstMap.getMap().addControl(new MousePosition());<br>
firstMap.getMap().addControl(new LayerSwitcher());<br>
firstMap.getMap().setCenter(new LonLat(-111.04, 45.68), 3);<br>
<br>
MapWidget secondMap = new MapWidget("350px", "350px",
defaultMapOptions); <br>
add(secondMap, DockPanel.WEST);<br>
secondMap.getMap().addLayers(new Layer[] { new Google("Google 2")
});<br>
secondMap.getMap().addControl(new PanZoomBar());<br>
secondMap.getMap().addControl(new NavToolBar());<br>
secondMap.getMap().addControl(new MousePosition());<br>
secondMap.getMap().addControl(new LayerSwitcher());<br>
<br>
// Center and Zoom<br>
secondMap.getMap().setCenter(new LonLat(-111.04, 45.68), 3);<br>
}<br>
<br>
public Map getMap() {<br>
return this.map;<br>
}<br>
<br>
public void destroy() {<br>
this.map.destroy();<br>
for (int i = 0, max = widgets.size(); i < max; i++) {<br>
this.remove(widgets.get(i));<br>
}<br>
;<br>
}<br>
<br>
public void add(Widget w, DockLayoutConstant c) {<br>
super.add(w, c);<br>
this.widgets.add(w);<br>
}<br>
}</tt></b><br>
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>
|