Revert "[android] #2588 - Make getTopOffsetPixelsForAnnotationSymbol private."

This reverts commit 67f0108389.
This commit is contained in:
Tobrun
2015-10-13 16:52:40 +02:00
parent 67f0108389
commit 7153f123df
5 changed files with 30 additions and 33 deletions

View File

@@ -84,10 +84,12 @@ public final class InfoWindow {
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
PointF coords = mMapView.toScreenLocation(position);
double y = mMapView.getTopOffsetPixelsForAnnotationSymbol(object.getSprite());
y = y * mMapView.getScreenDensity();
lp.leftMargin = (int) coords.x - (mView.getMeasuredWidth() / 2) + offsetX;
lp.leftMargin = (int) coords.x - (mView.getMeasuredWidth() / 2);
// Add y because it's a negative value
lp.topMargin = (int) coords.y - mView.getMeasuredHeight() + offsetY;
lp.topMargin = (int) coords.y - mView.getMeasuredHeight() + (int) y;
close(); //if it was already opened
mMapView.addView(mView, lp);

View File

@@ -15,15 +15,14 @@ public class Marker extends Annotation {
private boolean flat;
private float infoWindowAnchorU;
private float infoWindowAnchorV;
private LatLng position;
LatLng position;
private float rotation;
private String snippet;
private String sprite = "default_marker";
String sprite = "default_marker";
private String title;
private InfoWindow infoWindow = null;
private boolean infoWindowShown = false;
private int topOffsetPixels;
/**
* Constructor
@@ -125,7 +124,7 @@ public class Marker extends Annotation {
infoWindowAnchorV = v;
}
public void setPosition(LatLng position) {
public void setPosition(LatLng latlng) {
this.position = position;
}
@@ -162,26 +161,26 @@ public class Marker extends Annotation {
}
public void showInfoWindow() {
if (!isVisible() || mapView == null) {
return;
}
getInfoWindow().adaptDefaultMarker(this);
showInfoWindow(getInfoWindow());
getInfoWindow().open(this, getPosition(), (int) anchorU, (int) anchorV);
getInfoWindow().setBoundMarker(this);
infoWindowShown = true;
}
public void showInfoWindow(View view){
if (!isVisible() || mapView == null) {
return;
}
infoWindow = new InfoWindow(view, mapView);
showInfoWindow(infoWindow);
}
private void showInfoWindow(InfoWindow iw) {
iw.open(this, getPosition(), (int) anchorU, (int) anchorV + topOffsetPixels);
iw.setBoundMarker(this);
infoWindow.open(this, getPosition(), (int) anchorU, (int) anchorV);
infoWindow.setBoundMarker(this);
infoWindowShown = true;
}
@@ -223,8 +222,4 @@ public class Marker extends Annotation {
// void setIcon(BitmapDescriptor icon) {
//
// }
void setTopOffsetPixels(int topOffsetPixels) {
this.topOffsetPixels = topOffsetPixels;
}
}

View File

@@ -46,8 +46,7 @@ public class MarkerOptions extends AnnotationOptions {
return ((Marker)annotation).getInfoWindowAnchorV();
}
public Marker getMarker(int topOffsetPixels) {
((Marker)annotation).setTopOffsetPixels(topOffsetPixels);
public Marker getMarker() {
return (Marker)annotation;
}
@@ -67,10 +66,6 @@ public class MarkerOptions extends AnnotationOptions {
return ((Marker)annotation).getTitle();
}
public String getSprite() {
return ((Marker)annotation).getSprite();
}
public MarkerOptions infoWindowAnchor(float u, float v) {
((Marker)annotation).setInfoWindowAnchor(u, v);
return this;
@@ -89,7 +84,7 @@ public class MarkerOptions extends AnnotationOptions {
}
public MarkerOptions position(LatLng position) {
((Marker)annotation).setPosition(position);
((Marker)annotation).position = position;
return this;
}
@@ -105,7 +100,7 @@ public class MarkerOptions extends AnnotationOptions {
public MarkerOptions sprite(@Nullable String sprite) {
if (!TextUtils.isEmpty(sprite)) {
((Marker)annotation).setSprite(sprite);
((Marker)annotation).sprite = sprite;
}
return this;
}

View File

@@ -1596,7 +1596,7 @@ public final class MapView extends FrameLayout {
throw new NullPointerException("markerOptions is null");
}
Marker marker = markerOptions.getMarker(getTopOffsetPixelsForAnnotationSymbol(markerOptions.getSprite()));
Marker marker = markerOptions.getMarker();
// Load the default marker sprite
if (marker.getSprite() == null) {
@@ -1634,7 +1634,7 @@ public final class MapView extends FrameLayout {
List<Marker> markers = new ArrayList<>(markerOptionsList.size());
for (MarkerOptions markerOptions : markerOptionsList) {
Marker marker = markerOptions.getMarker(getTopOffsetPixelsForAnnotationSymbol(markerOptions.getSprite()));
Marker marker = markerOptions.getMarker();
// Load the default marker sprite
if (marker.getSprite() == null) {
@@ -1646,7 +1646,7 @@ public final class MapView extends FrameLayout {
marker.setSprite("default_marker");
//marker.setSprite(DEFAULT_SPRITE);
}
markers.add(marker);
markers.add(markerOptions.getMarker());
}
long[] ids = mNativeMapView.addMarkers(markers);
@@ -1857,8 +1857,8 @@ public final class MapView extends FrameLayout {
* @param symbolName Annotation Symbol
* @return Top Offset in pixels
*/
private int getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
return (int) (mNativeMapView.getTopOffsetPixelsForAnnotationSymbol(symbolName) * mScreenDensity);
public double getTopOffsetPixelsForAnnotationSymbol(@NonNull String symbolName) {
return mNativeMapView.getTopOffsetPixelsForAnnotationSymbol(symbolName);
}
/**
@@ -1875,6 +1875,14 @@ public final class MapView extends FrameLayout {
return mNativeMapView.getMetersPerPixelAtLatitude(latitude, getZoomLevel());
}
/**
* Get ScreenDensity of device
* @return Screen Density ratio
*/
public float getScreenDensity() {
return mScreenDensity;
}
private void selectMarker(Marker marker) {
if (marker == null) {
return;