Search in sources :

Example 1 with ItemizedOverlayWithFocus

use of org.osmdroid.views.overlay.ItemizedOverlayWithFocus in project QR-Game by CMPUT301W22T15.

the class GameMap method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_map);
    Toast.makeText(GameMap.this, "lat " + singletonPlayer.lat + " lon " + singletonPlayer.lon, Toast.LENGTH_SHORT).show();
    items = new ArrayList<>();
    // fetch all players --------------------
    // TODO: snapshot listener might cause issues when players get updated real time. whil
    // TODO: tryna cmput coordinates.
    allPlayers = new ArrayList<>();
    db = FirebaseFirestore.getInstance();
    final CollectionReference collectionReference = db.collection("Players");
    Configuration.getInstance().load(getApplicationContext(), PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
    map = findViewById(R.id.map);
    // render
    map.setTileSource(TileSourceFactory.MAPNIK);
    // zoomable
    map.setBuiltInZoomControls(true);
    // change start point
    GeoPoint startPoint = new GeoPoint(53.52289, -113.52503);
    // if user saved his current location
    if (singletonPlayer.lat != -1 && singletonPlayer.lon != -1) {
        startPoint = new GeoPoint(singletonPlayer.lat, singletonPlayer.lon);
    }
    IMapController mapController = map.getController();
    mapController.setCenter(startPoint);
    mapController.setZoom(18.0);
    String go = "53.607426, -113.529866";
    // items = new ArrayList<>();
    OverlayItem home = new OverlayItem("Em's test office", "my test office", new GeoPoint(53.600044, -113.530837));
    Drawable m = home.getMarker(0);
    items.add(home);
    populateMap();
    ItemizedOverlayWithFocus<OverlayItem> mOverlay = new ItemizedOverlayWithFocus<OverlayItem>(getApplicationContext(), items, new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {

        @Override
        public boolean onItemSingleTapUp(int index, OverlayItem item) {
            return true;
        }

        @Override
        public boolean onItemLongPress(int index, OverlayItem item) {
            return false;
        }
    });
    mOverlay.setFocusItemsOnTap(true);
    map.getOverlays().add(mOverlay);
}
Also used : OverlayItem(org.osmdroid.views.overlay.OverlayItem) Drawable(android.graphics.drawable.Drawable) CollectionReference(com.google.firebase.firestore.CollectionReference) GeoPoint(org.osmdroid.util.GeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) ItemizedOverlayWithFocus(org.osmdroid.views.overlay.ItemizedOverlayWithFocus) IMapController(org.osmdroid.api.IMapController) ItemizedIconOverlay(org.osmdroid.views.overlay.ItemizedIconOverlay)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 CollectionReference (com.google.firebase.firestore.CollectionReference)1 IMapController (org.osmdroid.api.IMapController)1 GeoPoint (org.osmdroid.util.GeoPoint)1 ItemizedIconOverlay (org.osmdroid.views.overlay.ItemizedIconOverlay)1 ItemizedOverlayWithFocus (org.osmdroid.views.overlay.ItemizedOverlayWithFocus)1 OverlayItem (org.osmdroid.views.overlay.OverlayItem)1