I think that you forget to transform the destination LonLat in the click handler as you did in the center point and the feature point.
On Monday, March 30, 2015 at 11:53:05 AM UTC+2, Jostein wrote:
-- On Monday, March 30, 2015 at 11:53:05 AM UTC+2, Jostein wrote:
HiThe code below creates a map and shows a point. The button below the map "Move point" should move the point a few hundred meters, but the point just disappears. What am I missing here?public class Maptest implements EntryPoint {private static final Projection DEFAULT_PROJECTION = new Projection("EPSG:4326");VectorFeature pointFeature;Vector markerLayer;public void onModuleLoad() {MapOptions defaultMapOptions = new MapOptions();MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);OSM osmMapnik = OSM.Mapnik("Mapnik");OSM osmCycle = OSM.CycleMap("CycleMap");//mapWidget.getMap().addControl(new LayerSwitcher()); osmMapnik.setIsBaseLayer(true); osmCycle.setIsBaseLayer(true);mapWidget.getMap().addLayer(osmMapnik); mapWidget.getMap().addLayer(osmCycle); markerLayer = new Vector("Marker layer");mapWidget.getMap().addLayer(markerLayer); LonLat lonLat = new LonLat(10.44136762, 63.39698564);lonLat.transform("EPSG:4326", mapWidget.getMap().getProjection()); //transform lonlat (provided in EPSG:4326) to OSM coordinate system (the map projection) mapWidget.getMap().setCenter(lonLat, 12); // Tegner et punktStyle pointStyle = new Style();pointStyle.setFillColor("red"); pointStyle.setStrokeColor("green"); pointStyle.setStrokeWidth(2);pointStyle.setFillOpacity(0.9); final Point point = new Point(10.44136762, 63.39698564);point.transform(DEFAULT_PROJECTION, new Projection(mapWidget .getMap().getProjection())); // transform point to OSM// coordinate systempointFeature = new VectorFeature(point, pointStyle);markerLayer.addFeature(pointFeature); //pointId = point.getId();Button b = new Button("Move point");b.addClickHandler(new ClickHandler() {@Overridepublic void onClick(ClickEvent event) {pointFeature.move(new LonLat(10.44215018, 63.35392463));}});VerticalPanel v = new VerticalPanel();v.add(mapWidget);v.add(b);RootLayoutPanel.get().add(v);}}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment