Comments (7)
It's possible. There are a couple ways you could do it. The easiest would probably to be add your own layer, a new ScalingLayout, sync the scale to the TileView, and add Views to it as you have above. The following is off the top of my head and is not complete, but should get you started.
- Make a new ScalingLayout class that sync it's scale to the TileView
public class HighlightLayer extends ScalingLayout implements DetailLevelEventListener {
public HighlightLayer ( Context context, DetailManager detailManager ) {
super( context );
detailManager.addDetailLevelEventListener( this );
}
@Override
public void onDetailLevelChanged() {
}
@Override
public void onDetailScaleChanged( double scale ) {
setScale( scale );
}
}
- Add it as a new layer to the TileView
HighlightManager highlightManager = new HighlightManager(this);
tileView.addView(highlightManager);
- Add Views to it...
ImageView areaPin = new ImageView(this);
int RED_FADE = Color.argb(100, 209, 50, 57);
areaPin.setBackgroundColor(RED_FADE);
areaPin.setMinimumWidth(40);
areaPin.setMinimumHeight(100);
ScalingLayout.LayoutParams lp = new ScalingLayout.LayoutParams(40, 100, 1200, 1225);
highlightManager.addView(areaPin, lp);
You could also achieve what you're trying to do with a combination of a custom path drawing implementation and a hotspot.
Last thing - if you're using the TileViewDemo as the source, it does not have the latest TileView lib - grab the latest jar from the releases page.
HTH, post back if you need more help, or the idea above won't work for you.
from tileview.
Thanks so much for responding! Could you elaborate a little more on what I'd need to do inside the Highlight Manager? I have the above implemented, but it results in the area moving around when zoomed. I think this is the right path to go down, I'm just not sure how to proceed. Any details you can provide would be helpful. Thanks!
from tileview.
I ended up doing it a little differently, so you didn't have to hack the core (and can use the jar and keep up to date with the latest release).
I ran a quick test and it works.
The idea is the same, but we get there a little differently.
All this happens in the Activity containing the TileView instance.
A. Create a reference to a ScalingLayout:
private ScalingLayout highlightManager;
B. Create a listener to pass the scale of the TileView to the ScalingLayout
private TileView.TileViewEventListenerImplementation listener = new TileView.TileViewEventListenerImplementation(){
@Override
public void onScaleChanged( double scale ){
highlightManager.setScale( scale );
}
};
C. in onCreate, set them up:
// add the listener
tileView.addTileViewEventListener( listener );
// instantiate the ScalingLayout and add it to the view tree
highlightManager = new ScalingLayout(this);
tileView.addView(highlightManager);
// draw some highlights
ImageView areaPin = new ImageView(this);
int RED_FADE = Color.argb(100, 209, 50, 57);
areaPin.setBackgroundColor(RED_FADE);
areaPin.setMinimumWidth(40);
areaPin.setMinimumHeight(100);
ScalingLayout.LayoutParams lp = new ScalingLayout.LayoutParams(40, 100, 1200, 1225);
highlightManager.addView(areaPin, lp);
That should do it. The dimensions are relative to the map at it's full size.
LMK if that's what you were looking for.
from tileview.
Got it! That is what I was looking for. I also added a HotSpot with the same dimensions to gather click events on it, since I don't think there's another way to do that with this implementation.
One further question.. is there any way to make this layer draw beneath the markers?
from tileview.
I also added a HotSpot with the same dimensions to gather click events on it, since I don't think there's another way to do that with this implementation.
You can add a plain-ol' View.OnClickListener to the ImageView, instead of using a HotSpot (but that will consume TouchEvents, so for example if you touched the highlighted area it wouldn't initiate a drag action - this might be OK or might not, depending on the exact nature of your setup).
is there any way to make this layer draw beneath the markers?
Honestly I don't remember how I did the addView overrides, since all children are routed through a "proxy" view, but you can _try_ to use addView(child, index)
, so instead of tileView.addView(highlightManager);
use tileView.addView(highlightManager, 2);
(which, in theory, should put it above the tiles but below paths and markers).
LMK how it goes
from tileview.
As for the layering, using tileView.addView(highlightManager, 2);
worked exactly as expected. I think I have everything I need for that part now.
You can add a plain-ol' View.OnClickListener to the ImageView, instead of using a HotSpot (but that will consume TouchEvents, so for example if you touched the highlighted area it wouldn't initiate a drag action - this might be OK or might not, depending on the exact nature of your setup).
As for the clicking, I actually tried to add a plain View.OnClickListener to the ImageView and for some reason it wouldn't fire, that's why I resorted to the HotSpot. I'll try it again just in case, otherwise I think the HotSpot will work.
Thanks again for the help.
from tileview.
NP, sounds good. Close the issue when you've got everything settled.
from tileview.
Related Issues (20)
- Remote tile demo freezes and crashes HOT 2
- Combine smooth scroll and scale HOT 2
- Tiles not properly laid out when Scale < 1 with remote tiles HOT 15
- Open source but no license? HOT 2
- Markers disappear when zooming HOT 4
- Cannot add tile images on the fly HOT 1
- StreamProvider asked to provide data for rows and columns out of bounds with to small images HOT 5
- Tiles outside the image are created HOT 8
- White text on white background in Advanved Tile Demo HOT 1
- Get touched position when touch on the tileview (version 4.0.7)
- longtouch
- App killed in background crashes when returning to foreground HOT 1
- `android.os.BadParcelableException` regarding `com.moagrius.widget.ScrollView$SavedState.<init>` HOT 1
- Use in viewholder for recycler view. HOT 2
- build() method starts to return void instead of TileView HOT 1
- Mike passed away HOT 5
- Does this lib support SVG format
- JCenter -> MavenCenter
- implementation 'com.qozix:tileview:2.7.7' doesn't seem to work HOT 1
- Impossible import com.qozix.tileview HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tileview.