moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

How i can know if a marker is currently displayed in the TileView? #451

Closed Amattia closed 6 years ago

Amattia commented 6 years ago

I have implemented in an Android project, a function that display a TileView to the user.

Using the listener of the touch, is is possible add a marker in a TileView, for a problem due to a bug (maybe) sometimes the marker is not added to the TileView.

I denotated this problem because I need to save the coordinates of the marker in a database and sometimes the number of the marker on the screen is less than the number of the record in the database.

Now, is it possible knwo if a marker is currently displayed in a tileView ? If yes how ?

This is the function that I used to add marker in TileView

public void addNewPin(CoordinatesDamage coordinate, boolean addInDB) {
    try {
        ImageView newImageView = new ImageView(getApplicationContext());
        newImageView.setTag(coordinate);
        newImageView.setImageResource(R.drawable.ico_marker);
        newImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                tileView.getCalloutLayout().removeAllViewsInLayout();
                setCallout(view, true);
            }
        });
        tileView.addMarker(newImageView, coordinate.getCoordX(), coordinate.getCoordY(), -0.5f, -1.0f);
        db.addCoordinates(coordinate, activityWizard, activityIncarico);
        listNewView.add(newImageView);
    } catch (Exception e) {
        //
    }
}
moagrius commented 6 years ago

mTileView.getMarkerLayout().indexOfChild(someMarker) > -1?