ऐसा करने के लिए कोई आसान तरीका है। हालांकि, मैं आपकी मदद कर सकता हूं।
import android.os.Handler;
public class Tween {
public static interface TweenCallback {
public void onTick(float time, long duration);
public void onFinished();
}
long start;
long duration;
Handler handler;
TweenCallback callback;
public Tween(TweenCallback callback) {
handler = new Handler();
this.callback = callback;
}
public void start(final int duration) {
start = android.os.SystemClock.uptimeMillis();
this.duration = duration;
tickRunnable.run();
}
public void stop() {
handler.removeCallbacks(tickRunnable);
}
Runnable tickRunnable= new Runnable() {
public void run() {
long now = android.os.SystemClock.uptimeMillis();
float time = now - start;
boolean finished = (time >= duration);
if (finished) {
time = duration;
}
callback.onTick(time, duration);
if (!finished) {
handler.post(tickRunnable);
}
else {
callback.onFinished();
}
}
};
//
// Tweening functions. The 4 parameters are :
//
// t - time, ranges from 0 to d
// b - begin, i.e. the initial value for the quantity being changed over time
// c - change, the amount b will be changed by at the end
// d - duration, of the transition, normally in milliseconds.
//
// All were adapted from http://jstween.sourceforge.net/Tween.js
//
public static float strongEaseInOut(float t, float b, float c, float d) {
t/=d/2;
if (t < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
}
public static float regularEaseIn(float t, float b, float c, float d) {
return c*(t/=d)*t + b;
}
public static float strongEaseIn(float t, float b, float c, float d) {
return c*(t/=d)*t*t*t*t + b;
}
}
मैं क्या सुझाव है कि आप एक बीच के साथ संयोजन के रूप में MapController.zoomToSpan()
का उपयोग है ... यहाँ कुछ पूरी तरह से है:
सबसे पहले, यहाँ मेरी निजी उपयोगिता वर्गों में से एक की एक मुफ्त उपहार, Tween.java है अवांछित कोड जो काम करना चाहिए, शायद एक चिमटा या दो के साथ, आप इसे लक्ष्य लैट & लोन स्पैन पास कर सकते हैं। :
public void slowZoom(int latE6spanTarget, int lonE6spanTarget) {
final float initialLatE6span = mapView.getLatitudeSpan();
final float initialLonE6span = mapView.getLongitudeSpan();
final float latSpanChange = (float)(latE6spanTarget - initialLatE6span);
final float lonSpanChange = (float)(lonE6spanTarget - initialLonE6span);
Tween tween = new Tween(new Tween.TweenCallback() {
public void onTick(float time, long duration) {
float latSpan = Tween.strongEaseIn(time, initialLatE6span, latSpanChange, duration);
float lonSpan = Tween.strongEaseIn(time, initialLonE6span, lonSpanChange, duration);
mapView.getController().zoomToSpan((int)latSpan, (int)lonSpan);
}
public void onFinished() {
}
});
tween.start(5000);
}
गति का एक बड़ा लाभ यह एनिमेटेड है वहाँ जाता है: बेकार भरी हुई छवियों की राशि है कम किया हुआ। नमूना @ 1ka और @ रूबेन के साथ काम करते समय, इसके परिणामस्वरूप 3 जी/यूएमटीएस नेटवर्क पर बहुत से बिटमैप लोडिंग कॉल पर 350 एमएम दूर फेंक दिया जाएगा। बैंडविड्थ का कचरा और कभी-कभी उपयोगकर्ता से शुद्ध धन होता है। यह भी सलाह दी जाती है कि पीसी-ब्राउज़र में भी Google मानचित्र इस तरह से काम करता है और हर किसी के लिए इसका उपयोग किया जाता है। कोई भी उम्मीद नहीं करता कि प्रदर्शित स्थान स्विच करते समय एक मानचित्र पहले ही लोड हो चुका है। – WarrenFaith