Closed morhpeus87 closed 5 years ago
Instead of trying to access the View like that, just use the variable you already have that is used to set the renderable of the node that gets put into the marker constructor.
node.setRenderable(renderable);
e.g. the renderable variable in the code above.
Also note, I don't think you can use the same renderable for more than 1 marker, you have to create a new one for each marker you want to make.
Hi! Thank you for the response! You're right, i cannot use the same renderable form more than 1 marker, it ends up by all marker having the same string wrote in it. So I come to this solution:
Here's my gist example https://gist.github.com/morhpeus87/f64b6598632dc959abb970e7f21c68c0
This was the only solution i came up with, what do you think? Is there any better and efficient method to achieve the same result?
Thank you!
Hi everyone! I'm trying to render multiple ViewRenderable representig locations around my current position. Everything works fine, when i tap on the marker the toast shows me te correct place name and distance. I would also like to write this informations inside the view rendered in the node. So as suggested in the example, I set setRenderEvent on every marker I create. From the given node i would like to get the current renderable, access the textview and setting the current node distance. I wrote this:
marker.setRenderEvent(n -> { Log.d(LOGTAG, "in render event"); Log.d(LOGTAG, "distance " + n.getDistance()); ViewRenderable renderable = (ViewRenderable)n.getRenderable(); if(renderable != null) { View view = renderable.getView(); TextView distanceTextView = view.findViewById(R.id.textViewLocationDistance); distanceTextView.setText(n.getDistance() + " M"); } });
But the renderable is always null and the node has an empty red background.
What am I missing? Any suggestions?
Thanks!