Coder Social home page Coder Social logo

Comments (6)

moagrius avatar moagrius commented on June 21, 2024

08-07 15:59:00.230: E/AndroidRuntime(20562): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

Looks like you're trying to add a View that's already in another ViewParent. You need to detach it from the display list before adding it (just like you would with any addView call).

HTH, LMK if that solves it.

from tileview.

klattimer avatar klattimer commented on June 21, 2024

Seems I was re-using the marker imageview when I shouldn't have been, I've fixed that problem and also fixed an off-by-one error in the DetailLevelPatternParserDefault which was causing my map to mis-align by one tile. However the markers never stay in the same location relative to the map, they shift back as if they too are off by one tile.

from tileview.

klattimer avatar klattimer commented on June 21, 2024

I figured out why the markers aren't aligned and I'm not sure if it is intentional. Initially I'd specified the anchor x/y to be 0.5, 1.0 (e.g. from the top left, half the width in and the entire height down) however it appears that this is incorrect and instead I've used -0.5 and -1.0 which seem to work a lot better. This is not intuitive as you would imagine that you're effectively specifying a percentage of the image width and height. I imagine that this is because you want to shift the anchor point by half the width in the negative direction however from an API perspective it's slightly confusing.

from tileview.

moagrius avatar moagrius commented on June 21, 2024

The math is x + (child.measuredWidth * anchorX)

It's much more common to have a google-maps style offset, where the image is pointing down and centered over the point, but I believe implying a negative offset is presumptive. It's actually gone back and forth between the (implied negative, or not) in the old widget (MapView)

from tileview.

klattimer avatar klattimer commented on June 21, 2024

I think what you should try to express is the percentage from top left of the image (or even bottom left) to the pixel of the image you wish to align with the point you're specifying on the map. So flipping these to imply a positive is better for the API consumer.

You can also, for instance specify exact pixel co-ordinates as per using 33 / image.getWidth(), 22 / image.getHeight() to calculate the anchors and the API consumer doesn't need to flip it.

from tileview.

moagrius avatar moagrius commented on June 21, 2024

It's been both ways (in the previous widget, MapView); I settled on this for a number of reasons, but mostly because presuming a google-maps style marker didn't make sense - this widget can be used for a variety of applications that aren't necessarily map-centric, and positive offsets are very likely. When setting offsets, I think flipping the sign implicitly is more confusing to the consumer.

FWIW, when it was implicitly flipped, users said the same thing, that it was confusing. I think it's mostly just personal preference, or the perspective from user's specific use case.

I'm always happy to try to fix bugs, or add features, but it's pretty unlikely I'll break the existing API. I am considering converting all TileView/ZoomPanLayout private members to protected, for more flexible extensions... I'll see if there's a need for that. Otherwise, feel free to fork your own version.

from tileview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.