मैप मैपर्स को मानचित्र में जोड़ते समय एनिमेट करना चाहते हैं।एंड्रॉइड पर मानचित्र में जोड़े जाने पर मार्कर को एनिमेट कैसे करें?
उपयोगकर्ता को अपने आस-पास के मार्करों के साथ नक्शा देखना चाहिए। प्रत्येक नए मार्कर को उछाल देना चाहिए।
मैप मैपर्स को मानचित्र में जोड़ते समय एनिमेट करना चाहते हैं।एंड्रॉइड पर मानचित्र में जोड़े जाने पर मार्कर को एनिमेट कैसे करें?
उपयोगकर्ता को अपने आस-पास के मार्करों के साथ नक्शा देखना चाहिए। प्रत्येक नए मार्कर को उछाल देना चाहिए।
नक्शा मार्कर के रूप में MapView के लिए किसी भी नए लेआउट जोड़ सकते हैं:
public void AddAnimMarkerToMap(MapView map, GeoPoint geoPoint, int id, int animResId)
{
var layoutParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent,
geoPoint,
MapView.LayoutParams.Center);
var ll = new LinearLayout(map.Context) { Id = id, Orientation = Orientation.Vertical };
ll.SetGravity(GravityFlags.Center);
var iv = new ImageView(map.Context);
iv.SetImageResource(animResId);
ll.AddView(iv);
map.AddView(ll, layoutParams);
var markerAnimation = (AnimationDrawable)iv.Drawable;
markerAnimation.Start();
ll.LayoutParameters = layoutParams;
}
शायद आप सीधे लेआउट wraping बिना imageView जोड़ सकते हैं। animResId फ़्रेम एनीमेशन ड्रॉबल संसाधन (एंड्रॉइड माइलोकेशन मार्कर के समान) है।
http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
आप onMarkerClick()
को लागू करने और उस पर मार्कर उछाल जब भी उपयोगकर्ता क्लिक कर सकते हैं। बस कोड कार्यान्वयन के नीचे आज़माएं। मैंने कोशिश की है और यह पूरी तरह से ठीक काम करता है।
private Marker mPerth; private Marker mPerth = mMap.addMarker(new MarkerOptions() .position(PERTH) .title("Perth") .snippet("Population: 1,738,800"));
@Override
public boolean onMarkerClick(final Marker marker)
{
// This causes the marker at Perth to bounce into position when it is clicked.
if (marker.equals(mPerth)) {
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj = mMap.getProjection();
Point startPoint = proj.toScreenLocation(PERTH);
startPoint.offset(0, -100);
final LatLng startLatLng = proj.fromScreenLocation(startPoint);
final long duration = 1500;
final Interpolator interpolator = new BounceInterpolator();
handler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed/duration);
double lng = t * PERTH.longitude + (1 - t) * startLatLng.longitude;
double lat = t * PERTH.latitude + (1 - t) * startLatLng.latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
// Post again 16ms later.
handler.postDelayed(this, 16);
}
}
});
}
// We return false to indicate that we have not consumed the event and that we wish
// for the default behavior to occur (which is for the camera to move such that the
// marker is centered and for the marker's info window to open, if it has one).
return false;
}
तुम भी onClick
घटना के अलावा अपने आवेदन में मार्कर जोड़ने के दौरान जो इस का उपयोग कर सकते हैं। मुझे उम्मीद है कि आप केवल यही चाहते हैं।
आप मेरे हीरो हैं, धन्यवाद! –
मैंने एक ही कोड की कोशिश की, लेकिन लाइन में त्रुटि हो रही है, इंटरपोलेटर इंटरपोलेटर = नया लीनियरइंटरपोलेटर(); "असंगत प्रकार" –
मार्कर ऑफ स्क्रीन या अपनी प्रारंभ स्थिति पर एंकर करें तो एनीमेशन शुरू करें।
नोट .setAnchor इस पद्धति में इस्तेमाल हो सकता है 2013
में गूगल मानचित्र API v2 में जोड़ा गया था मैं तो बस अब यह एक मार्कर के लिए काम एक्स्ट्रा कलाकार के नमूने नक्शे डेमो अदल-बदल करके मिल गया है और मैं डॉन ' इस कार्यान्वयन के प्रदर्शन की तरह टी। सबसे महत्वपूर्ण टुकड़ा मार्कर ऑफ स्क्रीन को बंद करना या अपनी प्रारंभ स्थिति में बंद करना है। मैं ऊपर ऑफ स्क्रीन का उपयोग कर रहा हूँ।
मार्कर ऑफ स्क्रीन स्क्रीन। एंटर (.5 एफ, (मार्कर/मार्कर के आकार के ऊपर स्क्रीन का आकार)) // मानचित्र के लिए डेमो पर्थ मेरे टेस्ट फोन के लिए लगभग 6 एफ है। एनीमेशन को उसी मान पर बाउंस करने के लिए बदलें यह मेरे परीक्षण फोन के लिए 6f था।
private void addMarkersToMap() {
// A few more markers for good measure.
mPerth = mMap.addMarker(new MarkerOptions().position(PERTH)
.title("Perth").snippet("Population: 1,738,800")
.anchor(.5f, 6f)
);
बदलें एनीमेशन तो यह (ऊपर मार्कर के मार्कर/आकार स्क्रीन के आकार) (अपने परीक्षण फोन पर 6F) को चली जाती है। मैं सिर्फ ऑनक्लिक हैंडलर का उपयोग कर रहा हूं क्योंकि यह पहले से ही 6f और लंबी अवधि के लिए tweaks उछाल के साथ उछाल के लिए सेट है। तो नक्शे पर सभी मार्कर जोड़े जाने के बाद मैं क्लिक हैंडलर से आग लगा देता हूं।
this.onMarkerClick(mPerth);
6f और लंबी अवधि के साथ मार्करक्लिक हैंडलर पर बदल गया।
@Override
public boolean onMarkerClick(final Marker marker) {
if (marker.equals(mPerth)) {
// This causes the marker at Perth to bounce into position when it
// is clicked.
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
final long duration = 2500;
final Interpolator interpolator = new BounceInterpolator();
handler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = Math.max(
1 - interpolator.getInterpolation((float) elapsed
/duration), 0);
marker.setAnchor(0.5f, 1.0f + 6 * t);
if (t > 0.0) {
// Post again 16ms later.
handler.postDelayed(this, 16);
}
}
});
} else if (marker.equals(mAdelaide)) {
// This causes the marker at Adelaide to change color.
marker.setIcon(BitmapDescriptorFactory.defaultMarker(new Random()
.nextFloat() * 360));
}
// We return false to indicate that we have not consumed the event and
// that we wish
// for the default behavior to occur (which is for the camera to move
// such that the
// marker is centered and for the marker's info window to open, if it
// has one).
return false;
}
गुड लक
उपयोग MapOverlay और मार्कर को बढ़ाने के लिए फ्रेम लेआउट, तो अपनी छवि दृश्य वस्तु तो एनीमेशन है कि नक्शे गतिविधि में शुरू हो जाओ। – Noby
मुझे लगता है कि यह लिंक आपके प्रश्न का उत्तर देता है: http: // stackoverflow।कॉम/प्रश्न/7407475/कैन-ए-यूज-एनीमेशन-ड्रा-इन-ए-ओवरले-ऑन-ए-मैप्यूव्यू –