Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): nonNull getPosition #649

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 5.6.1
version: 5.6.2
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: External version of Map module using native Google Maps library
Expand Down
3 changes: 2 additions & 1 deletion android/src/ti/map/TiClusterRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.View;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.maps.android.clustering.ClusterManager;
Expand Down Expand Up @@ -111,7 +112,7 @@ protected void onClusterItemUpdated(TiMarker item, Marker marker)
}
// Update marker position if the item changed position
if (!marker.getPosition().equals(item.getPosition())) {
if (item.getPosition() != null) {
if (!item.getPosition().equals(new LatLng(0, 0))) {
marker.setPosition(item.getPosition());
}
changed = true;
Expand Down
4 changes: 3 additions & 1 deletion android/src/ti/map/TiMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package ti.map;

import androidx.annotation.NonNull;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.maps.android.clustering.ClusterItem;
Expand Down Expand Up @@ -48,13 +49,14 @@ public void release()
}
}

@NonNull
@Override
public LatLng getPosition()
{
if (proxy != null) {
return proxy.getMarkerOptions().getPosition();
}
return null;
return new LatLng(0, 0);
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions android/src/ti/map/TiUIMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ protected void showAnnotations(Object[] annotations)

LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (TiMarker marker : markers) {
builder.include(marker.getPosition());
if (!marker.getPosition().equals(new LatLng(0, 0))) {
builder.include(marker.getPosition());
}
}
LatLngBounds bounds = builder.build();

Expand Down Expand Up @@ -645,7 +647,7 @@ protected void addAnnotation(AnnotationProxy annotation)
// It is assigned to the TiMarker instance after it has been rendered in
// onClusterItemRendered callback.
tiMarker = new TiMarker(null, annotation);
if (mClusterManager != null) {
if (mClusterManager != null && tiMarker != null) {
mClusterManager.addItem((TiMarker) tiMarker);
mClusterManager.cluster();
}
Expand Down
Loading