custom markers, gitignore for ds store noobish mac files

This commit is contained in:
Adam Domagalski 2018-11-03 01:31:39 +01:00
parent f57141d0f2
commit 8a0ccfa60a
7 changed files with 66 additions and 10 deletions

1
.gitignore vendored
View File

@ -65,3 +65,4 @@ fastlane/Preview.html
fastlane/screenshots fastlane/screenshots
fastlane/test_output fastlane/test_output
fastlane/readme.md fastlane/readme.md
app/src/main/res/.DS_Store

View File

@ -10,10 +10,13 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.util.Log; import android.util.Log;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.style.layers.CircleLayer; import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
@ -75,6 +78,7 @@ public class MapActivity extends BaseActivity
private MapView mapView; private MapView mapView;
private MapboxMap mapboxMap; private MapboxMap mapboxMap;
private Marker droppedMarker;
private HashMap<String, Coordinate> coordsMap = new HashMap<>(); private HashMap<String, Coordinate> coordsMap = new HashMap<>();
private HashMap<String, Marker> markerHash = new HashMap<>(); private HashMap<String, Marker> markerHash = new HashMap<>();
@ -109,8 +113,9 @@ public class MapActivity extends BaseActivity
} }
@Override @Override
public void onMapReady(MapboxMap map) { public void onMapReady(MapboxMap mapboxMap) {
mapboxMap = map; MapActivity.this.mapboxMap = mapboxMap;
// mapboxMap = map;
final Marker marker = mapboxMap.addMarker(new MarkerViewOptions() final Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
.position(new LatLng(52.466782, 16.927549))); .position(new LatLng(52.466782, 16.927549)));
mStatusChecker.run(); mStatusChecker.run();
@ -143,14 +148,63 @@ public class MapActivity extends BaseActivity
} }
private void setOnMapLongClickListener() { private void setOnMapLongClickListener() {
mapboxMap.addOnMapLongClickListener((LatLng latLng) -> { final boolean[] cancel = {false};
Log.e(tag, "eeeeee"); Button selectLocationButton = findViewById(R.id.select_location_button);
Button button = findViewById(R.id.select_location_button);
button.setVisibility(View.VISIBLE);
// button.setOnClickListener(() -> { mapboxMap.addOnMapLongClickListener((LatLng latLng) -> {
// selectLocationButton.setVisibility(View.VISIBLE);
// }); Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.green_marker);
if (droppedMarker == null) {
droppedMarker = mapboxMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(icon)
.title("My Loc")
.setSnippet("Snipecik"));
} else if (!cancel[0]){
ValueAnimator markerAnimator = ObjectAnimator.ofObject(droppedMarker, "position",
new mapUtils.LatLngEvaluator(), droppedMarker.getPosition(), latLng);
markerAnimator.setDuration(2000);
markerAnimator.start();
}
selectLocationButton.setOnClickListener((View view) -> {
if (!cancel[0] && droppedMarker != null){
// Toast instructing user to tap on the mapboxMap
Toast.makeText(
MapActivity.this,
"Manual Locations selected!" + latLng,
Toast.LENGTH_LONG
).show();
selectLocationButton.setBackgroundColor(
ContextCompat.getColor(MapActivity.this, R.color.colorAccent));
selectLocationButton.setText("Rm my loc");
selectLocationButton.setVisibility(View.VISIBLE);
cancel[0] = true;
} else {
mapboxMap.removeMarker(droppedMarker);
droppedMarker = null;
Toast.makeText(
MapActivity.this,
"REMOVED!!" + latLng,
Toast.LENGTH_LONG
).show();
cancel[0] = false;
selectLocationButton.setVisibility(View.GONE);
selectLocationButton.setText(R.string.select_a_location);
selectLocationButton.setBackgroundColor(
ContextCompat.getColor(MapActivity.this, R.color.colorPrimary));
}
});
}); });
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -97,7 +97,7 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_margin="8dp" android:layout_margin="8dp"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
android:text="Select a location" android:text="@string/select_a_location"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:visibility="gone" /> android:visibility="gone" />

View File

@ -202,5 +202,6 @@ functionality.</string>
<string name="fab_title_hotels">Hotels</string> <string name="fab_title_hotels">Hotels</string>
<string name="fab_title_parks">Parks</string> <string name="fab_title_parks">Parks</string>
<string name="fab_title_attractions">Attractions</string> <string name="fab_title_attractions">Attractions</string>
<string name="select_a_location">Select a location</string>
</resources> </resources>