Closed krmao closed 8 years ago
i'm really not clear what you're asking
sorry , my English is so poor! please see the image
android:scaleType="fitCenter"
.
but TileView looks like android:scaleType="centerCrop"
.
this function is like IOS-UIScrollView-contentOffset property.android:clipToPadding
to solve the first problem to let the smallest map show at padding area , because set paddingTop can let the smallest map looks like at View's center.clear the titleView to redraw another map data I used these code:
//reset titleView
if (getDetailLevelManager().getCurrentDetailLevel() != null)
getDetailLevelManager().resetDetailLevels();
the problem is not really clear, You can see the problem on the image I uploaded where marked by red 'x',also have some last-map-data cache show with new-map-data together.this function is looks like TileView.reset() or TileView.clear().
i think you might want to do something like this gentleman did in his fork: https://github.com/moagrius/TileView/pull/358
then you'd probably have to scroll to center. i'm not terribly familiar with the whole "fitMode" stuff and have never used it personally.
Thank you guys ,you reply so quickly!
I find the solution. For first question : if the primary picture's size is 5432 x 2612, i change it's canvas to 6000 x 6000 by photoshop. and it is shown on the center of TileView like ImageView's fitCenter.
For secondQuestion:
I Rewrite TileView,and add function named "reset", which can reused TileView to changed mapData.
public TileView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
public void init(Context context) {
mTileCanvasViewGroup = new TileCanvasViewGroup(context);
addView(mTileCanvasViewGroup);
mCompositePathView = new CompositePathView(context);
addView(mCompositePathView);
mScalingLayout = new ScalingLayout(context);
addView(mScalingLayout);
mMarkerLayout = new MarkerLayout(context);
addView(mMarkerLayout);
mCalloutLayout = new CalloutLayout(context);
addView(mCalloutLayout);
mDetailLevelManager.setDetailLevelChangeListener(this);
mTileCanvasViewGroup.setTileRenderListener(this);
addZoomPanListener(this);
mRenderThrottleHandler = new RenderThrottleHandler(this);
requestRender();
}
public void reset(Context context) {
removeView(mTileCanvasViewGroup);
removeView(mCompositePathView);
removeView(mScalingLayout);
removeView(mMarkerLayout);
removeView(mCalloutLayout);
mDetailLevelManager = new DetailLevelManager();
init(context);
}
and then use it, please notice the setScale
@SuppressWarnings("SuspiciousNameCombination")
public void setData(Activity activity, String layerId, String prePath, String extension) {
this.activity = activity;
layerEntity = LightMapUtil.getMapDataSize().get(layerId);
if (layerEntity == null)
return;
reset(activity);
setSize(layerEntity.size.getWidth(), layerEntity.size.getHeight());
// detail levels
addDetailLevel(1.000f, prePath + layerEntity.id + MAP_DATA_MULTIPLE + "/1000/%d_%d" + extension);
addDetailLevel(0.500f, prePath + layerEntity.id + MAP_DATA_MULTIPLE + "/500/%d_%d" + extension);
addDetailLevel(0.250f, prePath + layerEntity.id + MAP_DATA_MULTIPLE + "/250/%d_%d" + extension);
addDetailLevel(0.125f, prePath + layerEntity.id + MAP_DATA_MULTIPLE + "/125/%d_%d" + extension);
// lets center all markers both horizontally and vertically
defineBounds(0, 0, layerEntity.size.getWidth(), layerEntity.size.getHeight());
frameTo(layerEntity.size.getWidth() / 2, layerEntity.size.getHeight() / 2);
postDelayed(new Runnable() {
@Override
public void run() {
setScale(MAX_SCALE);
postDelayed(new Runnable() {
@Override
public void run() {
invalidate();
setScale(MIN_SCALE);
}
}, 100);
}
}, 100);
}
this is my perfect result:
glad you got it worked out
any idea set initMap to center ?or set padingTop and use android:clipToPadding="false" ,but not useable that is set some blank at padding left and padding top