Commits

Todor Todorov  committed 726227e

added getLonLatFromLayerPx methods

  • Participants
  • Parent commits 0cc28a5

Comments (0)

Files changed (2)

File gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/Map.java

     public void zoomToExtent(Bounds bounds) {
         MapImpl.zoomToExtent(getJSObject(), bounds.getJSObject());
     }
-    
+
     /**
      * APIMethod: zoomToExtent
      * Zoom to the passed in bounds, recenter.
      * @param bounds
-     * @param closest Find the zoom level that most closely fits the 
-     * specified bounds. Note that this may result in a zoom that does 
+     * @param closest Find the zoom level that most closely fits the
+     * specified bounds. Note that this may result in a zoom that does
      * not exactly contain the entire extent. Default is false.
      */
     public void zoomToExtent(Bounds bounds, boolean closest) {
                 lonlat.getJSObject()));
     }
 
+    /**
+     * APIMethod: getLayerPxFromLonLat
+     *
+     * Parameters:
+     * @param lonlat {<OpenLayers.LonLat>} lonlat
+     *
+     * @return {<OpenLayers.Pixel>} An OpenLayers.Pixel which is the passed-in
+     *                      <OpenLayers.LonLat>, translated into layer pixels
+     *                      by the current base layer
+     */
+    public Pixel getLayerPxFromLonLat(LonLat lonlat) {
+    	return new Pixel(MapImpl.getLayerPxFromLonLat(getJSObject(),
+    			lonlat.getJSObject()));
+    }
+
+    /**
+     * Method: getLonLatFromLayerPx
+     *
+     * Parameters:
+     * @param px - {<OpenLayers.Pixel>}
+     *
+     * @return {<OpenLayers.LonLat>}
+     */
+    public LonLat getLonLatFromLayerPx(Pixel px) {
+    	return new LonLat(MapImpl.getLonLatFromLayerPx(getJSObject(),
+    			px.getJSObject()));
+    }
+
     public String getProjection() {
         return MapImpl.getProjection(getJSObject());
     }

File gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/MapImpl.java

     public static native JSObject getControlsByClass(JSObject map, String className)/*-{
         return map.getControlsByClass(className)[0];
     }-*/;
-	
+
 	public static native JSObject getLayers(JSObject map)/*-{
 		return (map.layers === undefined) ? null : map.layers;
 	}-*/;
     public static native void removeLayer(JSObject map, JSObject layer, boolean setNewBaseLayer)/*-{
         map.removeLayer(layer, setNewBaseLayer);
     }-*/;
-	
+
 	public static native void removeControl(JSObject map, JSObject control)/*-{
 		map.removeControl(control);
 	}-*/;
 	public static native void setLayerIndex(JSObject map, JSObject layer, int index)/*-{
 		map.setLayerIndex(layer, index);
 	}-*/;
-	
+
     public static native void setLayerZIndex(JSObject map, JSObject layer, int zIdx)/*-{
         map.setLayerZIndex(layer, zIdx);
     }-*/;
 	public static native void zoomToExtent(JSObject map, JSObject bounds)/*-{
 		map.zoomToExtent(bounds);
 	}-*/;
-    
+
     public static native void zoomToExtent(JSObject map, JSObject bounds, boolean closest)/*-{
 		map.zoomToExtent(bounds, closest);
 	}-*/;
 	public static native JSObject getPixelFromLonLat(JSObject map, JSObject lonlat)/*-{
 		return map.getPixelFromLonLat(lonlat);
 	}-*/;
+
+	public static native JSObject getLayerPxFromLonLat(JSObject map, JSObject lonlat)/*-{
+		return map.getLayerPxFromLonLat(lonlat);
+	}-*/;
+
+	public static native JSObject getLonLatFromLayerPx(JSObject map, JSObject px)/*-{
+		return map.getLonLatFromLayerPx(px);
+	}-*/;
+
 	public static native String getProjection(JSObject map)/*-{
 		return map.getProjection();
 	}-*/;
 	public static native void zoomTo(JSObject map, int zoomLevel)/*-{
 		map.zoomTo(zoomLevel);
 	}-*/;
-	
+
     public static native void zoomToScale(JSObject map, float scale, boolean closest)/*-{
         map.zoomToScale(scale, closest);
     }-*/;
 	public static native void panTo(JSObject map, JSObject lonlat)/*-{
 		map.panTo(lonlat);
 	}-*/;
-	
+
 	public static native void pan(JSObject map, int dx, int dy) /*-{
 		map.pan(dx, dy);
 	}-*/;
 	public static native void setBaseLayer(JSObject map, JSObject newBaseLayer)/*-{
  		map.setBaseLayer(newBaseLayer);
 	}-*/;
-	
+
     public static native void disableBrowserContextMenu(JSObject map, BrowserMenuListener listener)/*-{
         map.div.oncontextmenu = function noContextMenu(e) {
         var eventObj = @org.gwtopenmaps.openlayers.client.event.MouseEvent::narrowToMouseEvent(Lorg/gwtopenmaps/openlayers/client/util/JSObject;)(e);
         listener.@org.gwtopenmaps.openlayers.client.Map.BrowserMenuListener::onMouseClick(Lorg/gwtopenmaps/openlayers/client/event/MouseEvent;)(eventObj);
-        
+
         return false; //cancel the right click of browser
-        }; 
+        };
     }-*/;
-    
-    
+
+
     public static native double getZoomForResolution(JSObject map, double resolution, boolean closest)/*-{
         return map.getZoomForResolution(resolution, closest);
     }-*/;