Hi there,
our service is maps heavy. We show maps in all sorts of places - layout, popups, form items, etc. We've done this for years, in all versions. Since there's no map components at all in smartGWT, we use a third-party library, branflake, to provide GWT bindings for Google's maps v3 javascript library. (github here: https://github.com/branflake2267/GWT-Maps-V3-Api)
However, we recently tried to upgrade from 5.0 to 5.1, more specifically from smartgwt pro 5.0-p20160409 to 5.1-p20160428, and just now 5.1-p20160514 (the issue is still there).
Basically what happens is that the gwt maps widget is totally blank, it doesn't draw anything, even though i can see that calls are being made to google to fetch data to display. There are no errors in the console that i can see.
This is totally crucial for us upgrading, so it would be super-great if someone could help out with this.
I have made a test-project to illustrate below. By just switching out the smartgwt jars, this project shows, or doesn't show, the actual map we're trying to display.
Thanks in advance.
our service is maps heavy. We show maps in all sorts of places - layout, popups, form items, etc. We've done this for years, in all versions. Since there's no map components at all in smartGWT, we use a third-party library, branflake, to provide GWT bindings for Google's maps v3 javascript library. (github here: https://github.com/branflake2267/GWT-Maps-V3-Api)
However, we recently tried to upgrade from 5.0 to 5.1, more specifically from smartgwt pro 5.0-p20160409 to 5.1-p20160428, and just now 5.1-p20160514 (the issue is still there).
Basically what happens is that the gwt maps widget is totally blank, it doesn't draw anything, even though i can see that calls are being made to google to fetch data to display. There are no errors in the console that i can see.
This is totally crucial for us upgrading, so it would be super-great if someone could help out with this.
I have made a test-project to illustrate below. By just switching out the smartgwt jars, this project shows, or doesn't show, the actual map we're trying to display.
Thanks in advance.
Code:
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.maps.client.LoadApi; import com.google.gwt.maps.client.MapWidget; import com.google.gwt.maps.client.base.LatLng; import com.google.gwt.maps.client.base.Point; import com.google.gwt.maps.client.overlays.Marker; import com.google.gwt.maps.client.overlays.MarkerImage; import com.google.gwt.maps.client.overlays.MarkerOptions; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.events.ResizedEvent; import com.smartgwt.client.widgets.events.ResizedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import java.util.ArrayList; public class Test implements EntryPoint { public void onModuleLoad() { Runnable onLoad = new Runnable() { @Override public void run() { initLayout(); } }; loadMapApi(onLoad); } public void initLayout() { try { VLayout mainLayout = new VLayout(); mainLayout.setWidth100(); mainLayout.setMembersMargin(30); mainLayout.setLayoutAlign(Alignment.CENTER); mainLayout.setLayoutTopMargin(20); MapLayoutWithWidget mapLayout = new MapLayoutWithWidget(); mainLayout.setDefaultLayoutAlign(Alignment.CENTER); mapLayout.setBorder("1px solid black"); mapLayout.setVisible(true); mapLayout.setHeight(200); mapLayout.setWidth(200); mapLayout.getWidget().setZoom(10); mainLayout.addMember(mapLayout); mainLayout.draw(); LatLng sweden = LatLng.newInstance(63.049649, 16.347656); mapLayout.createMarker(sweden, "hello", null, 0, 0, true, false, true); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } public class MapLayoutWithWidget extends HLayout { private MapWidget map; public MapLayoutWithWidget() { //we want to make sure that the map always takes up the entire layout, since it doesn't scale automatically. addResizedHandler(new ResizedHandler() { public void onResized(ResizedEvent e) { map.setSize(getWidth().toString(), getHeight().toString()); map.triggerResize(); } }); setRedrawOnResize(true); setWidth100(); setHeight100(); this.setMargin(0); this.setPadding(0); this.setMembersMargin(0); map = new MapWidget(null); map.setZoom(10); map.setWidth(getWidthAsString()); map.setHeight(getHeightAsString()); addMember(map); } /** * sets the position as a marker on the map, plus sets the title if it's not null. * We return the marker so that it later is possible to move it if desirable. * * [USER="45788"]param[/USER] location * [USER="45788"]param[/USER] hovertext * @return */ private Marker createMarker(LatLng location, String hovertext, String iconUrl, int iconAnchorX, int iconAnchorY, boolean setCenter, boolean draggable, boolean addToMap) { MarkerOptions options = MarkerOptions.newInstance(); options.setTitle(hovertext); options.setDraggable(draggable); if (iconUrl != null) { MarkerImage icon = MarkerImage.newInstance(iconUrl); icon.setAnchor(Point.newInstance(iconAnchorX, iconAnchorY)); options.setIcon(icon); } Marker m = Marker.newInstance(options); m.setPosition(location); if (addToMap) { m.setMap(map); } if (setCenter) { map.setCenter(location); } return m; } public MapWidget getWidget() { return map; } } public static boolean loadMapApi(Runnable runnable) { GWT.log("loadMapApi!"); boolean sensor = true; // load all the libs for use in the maps ArrayList<LoadApi.LoadLibrary> loadLibraries = new ArrayList<LoadApi.LoadLibrary>(); loadLibraries.add(LoadApi.LoadLibrary.DRAWING); loadLibraries.add(LoadApi.LoadLibrary.GEOMETRY); loadLibraries.add(LoadApi.LoadLibrary.PLACES); LoadApi.go(runnable, loadLibraries, sensor); return true; } }
Comment