API: remove Map.setMapCenter() -> use Map.setMapPosition
This commit is contained in:
parent
510c201e17
commit
ba9300da91
@ -276,7 +276,6 @@ public class SearchBox {
|
|||||||
pos.setZoomLevel(13);
|
pos.setZoomLevel(13);
|
||||||
pos.setPosition(d.getLatitude(), d.getLongitude());
|
pos.setPosition(d.getLatitude(), d.getLongitude());
|
||||||
map.setMapPosition(pos);
|
map.setMapPosition(pos);
|
||||||
map.updateMap(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scroller.setVisible(false);
|
scroller.setVisible(false);
|
||||||
|
|||||||
@ -84,6 +84,14 @@ public class MapPosition {
|
|||||||
MercatorProjection.toLongitude(x));
|
MercatorProjection.toLongitude(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getLatitude() {
|
||||||
|
return MercatorProjection.toLatitude(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLongitude() {
|
||||||
|
return MercatorProjection.toLongitude(x);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -102,4 +110,5 @@ public class MapPosition {
|
|||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import org.oscim.backend.Log;
|
import org.oscim.backend.Log;
|
||||||
import org.oscim.core.BoundingBox;
|
import org.oscim.core.BoundingBox;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.core.MercatorProjection;
|
|
||||||
import org.oscim.event.Dispatcher;
|
import org.oscim.event.Dispatcher;
|
||||||
import org.oscim.event.EventDispatcher;
|
import org.oscim.event.EventDispatcher;
|
||||||
import org.oscim.event.EventListener;
|
import org.oscim.event.EventListener;
|
||||||
@ -129,7 +128,6 @@ public abstract class Map implements EventDispatcher {
|
|||||||
* Request call to onUpdate for all layers. This function can
|
* Request call to onUpdate for all layers. This function can
|
||||||
* be called from any thread. Request will be handled on main
|
* be called from any thread. Request will be handled on main
|
||||||
* thread.
|
* thread.
|
||||||
*
|
|
||||||
* @param forceRedraw pass true to render next frame
|
* @param forceRedraw pass true to render next frame
|
||||||
*/
|
*/
|
||||||
public abstract void updateMap(boolean forceRedraw);
|
public abstract void updateMap(boolean forceRedraw);
|
||||||
@ -184,28 +182,29 @@ public abstract class Map implements EventDispatcher {
|
|||||||
mUpdateDispatcher.dispatch();
|
mUpdateDispatcher.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set {@link MapPosition} of {@link Viewport} and trigger a redraw.
|
||||||
|
*/
|
||||||
public void setMapPosition(MapPosition mapPosition) {
|
public void setMapPosition(MapPosition mapPosition) {
|
||||||
mViewport.setMapPosition(mapPosition);
|
mViewport.setMapPosition(mapPosition);
|
||||||
}
|
updateMap(true);
|
||||||
|
|
||||||
public void getMapPosition(MapPosition mapPosition) {
|
|
||||||
mViewport.getMapPosition(mapPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set center of the map viewport and trigger a redraw.
|
* Get current {@link MapPosition}.
|
||||||
*
|
* @param mapPosition
|
||||||
* @param latitude
|
|
||||||
* @param longitude
|
|
||||||
*/
|
*/
|
||||||
public void setMapCenter(double latitude, double longitude) {
|
public boolean getMapPosition(MapPosition mapPosition) {
|
||||||
latitude = MercatorProjection.limitLatitude(latitude);
|
return mViewport.getMapPosition(mapPosition);
|
||||||
longitude = MercatorProjection.limitLongitude(longitude);
|
}
|
||||||
mViewport.setPos(
|
|
||||||
MercatorProjection.longitudeToX(longitude),
|
|
||||||
MercatorProjection.latitudeToY(latitude));
|
|
||||||
|
|
||||||
updateMap(true);
|
/**
|
||||||
|
* Get current {@link MapPosition}.
|
||||||
|
*/
|
||||||
|
public MapPosition getMapPostion() {
|
||||||
|
MapPosition pos = new MapPosition();
|
||||||
|
mViewport.getMapPosition(pos);
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Viewport getViewport() {
|
public Viewport getViewport() {
|
||||||
@ -247,9 +246,8 @@ public abstract class Map implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener interface for map update notifications.
|
* Listener interface for map update notifications.
|
||||||
*
|
* NOTE: Layers implementing this interface they will be automatically
|
||||||
* NOTE: Layers implementing this interface they will be automatically
|
|
||||||
* registered when the layer is added to the map and unresitered when
|
* registered when the layer is added to the map and unresitered when
|
||||||
* the layer is removed.
|
* the layer is removed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user