Coder Social home page Coder Social logo

Comments (10)

tekblom avatar tekblom commented on August 25, 2024

This is run from a none UI thread, maybe that has something to do with it?

from tileview.

moagrius avatar moagrius commented on August 25, 2024

I don't think the threading is relevant. I suspect it's just that the layout mechanism used by markers and callouts is unfamiliar to you. You can check out TranslationLayout and AnchorLayout for details on how exactly markers are laid out, but the basic idea is that they're positioned based on the full-size map (whatever size you set with TileView.setSize, and those numbers are "scaled" so that they move with the tileview as it scales, but only positionally (not dimensionally). There's also anchor points to condiser, as is described here and here

Really everything significant is happening in TranslationLayout.onLayout, here - that should show you what's going on in broad strokes. If you're messing with x or y, then make sure that the values you're setting are relative to the full size image. If you're using width and height, refer to how anchors work.

Hope the helps - post back if not.

from tileview.

tekblom avatar tekblom commented on August 25, 2024

Thanks for your answer.

Though I cannot cast my LayoutParams to a AnchorLayout.LayoutParams. This is because my View is contained inside an RelativeLayout. This is my code before the change that causes it to get out of sync when zooming.

My Callout view:

<FrameLayout ...>
...
<RelativeLayout ..>
             <ImageView  android:id="@+id/car_callout_health_bar"
                                   ../>
</RelativeLayout>
...
</FrameLayout>

My Callout.java:

updateCallout()  {
  ViewGroup.LayoutParams healthParams = findViewById(R.id.car_callout_health_bar).getLayoutParams();
  healthParams.width = (int) (getResources().getDimension(R.dimen.car_callout_total_bar_width) * car.health);
  findViewById(R.id.car_callout_health_bar).setLayoutParams(healthParams);
}

Shouldn't I be able to change the LayoutParams inside an MarkerView without AnchorLayout? E.g. I need the RelativeLayout to position my ImageView.

from tileview.

moagrius avatar moagrius commented on August 25, 2024

sure, the Marker can be anything at all (I generally use RelativeLayout myself - available for review in the demo app). That said, the change in width will affect the total width of the parent (Marker/Callout), which will affect how the anchor value is calculated. Do you understand how the anchor float values work? Have you tried a 0,0 anchor point (so the marker will have it's top-left corner aligned with the pixel position provided).

I'm still not 100% clear on what's happening - can you describe in detail the issue you're experiencing? If you'd like to share your app, I'd be happy to take a look.

from tileview.

tekblom avatar tekblom commented on August 25, 2024

Just to let you know. I have recreated my views in the demo app and I don't get the problem there. I will dig into it a bit more later this or the next week and find what is causing the error in my app.

from tileview.

moagrius avatar moagrius commented on August 25, 2024

sounds good. good luck

from tileview.

Sikter avatar Sikter commented on August 25, 2024

Hi moagrius, I don't want open new issue (I will if needed be :D ) for my small question thats kinda related to this one. You said markers are scaled positionally with TileView and I understand that, but not dimensionally. What's the most elegant way to scale markers dimensionally with TileView?

from tileview.

moagrius avatar moagrius commented on August 25, 2024

Hi @Sikter,

There's no way out-of-the-box to do that. I'd probably recommend adding a new ScalingLayout to the TileView. If you can use pixel values (relative to the original/fullsize or largest tile set), it should be fairly easy to implement - if you need to use a coordinate system it could get a little trickier.

You could also have each marker do it's own scaling, and have it listen to scale changes and react appropriately. The basic operation is pretty simple to have a View/Group scale - the concept can be seen pretty quickly in the very short ScalingLayout class (I'm not suggesting you use the class necessarily, but it does show a simple way to scale a View/Group).

Post back (in a new issue, as these are substantively different ideas) if you need more help.

from tileview.

tekblom avatar tekblom commented on August 25, 2024

I solved this one !

It was becuase I didn't updated the views on ui-thread.

Thanks for the help!

from tileview.

moagrius avatar moagrius commented on August 25, 2024

Glad you got it worked out.

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.