Bir MapView
sahibiyim ve her biri aynı çekilebilir ancak farklı bilgilerle 1,700 puan üzerine bindiriyorum. Şu anda tüm bindirmeleri eklemek için Öğe Öğesi Yerleşimi kullanıyorum ve ardından bir kez doldu. Bu çalışır, ancak performans yavaştır. Zum seviyesini değiştirmek ve odaklanmak ürkütücüdür. Şimdi, aynı çekilebilir olduğu için ArrayItemizedOverlay
'u kullanmak daha mı iyi olurdu yoksa harita bu kadar yavaş mı? (MapView ve 1700 Bindirme Öğeleri) .equals ("Yavaş")
import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.app.Activity;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
public class Points extends ItemizedOverlay <OverlayItem> {
Context mContext;
private ArrayList mOverlays = new ArrayList();
String newLine = String.format("%n");
public Points(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
// TODO Auto-generated constructor stub
}
@Override
protected OverlayItem createItem(int i) {
return (OverlayItem) mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
@Override
public void draw(Canvas canvas,
MapView mapView,
boolean shadow) {
if (!shadow)
super.draw(canvas, mapView, shadow);
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
}
public void populateNow(){
setLastFocusedIndex(-1);
populate();
}
public Points(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
@Override
protected boolean onTap(int index) {
Intent intent = new Intent();
OverlayItem item = (OverlayItem) mOverlays.get(index);
AlertDialog.Builder dialog1 = new AlertDialog.Builder(mContext);
dialog1.setTitle(item.getTitle());
String info = item.getSnippet();
String delims = "[$]";
String [] tokens = info.split(delims);
String info1 = tokens [0];
String info2 = tokens[1];
String delims2 = "[!]";
String [] tokens2 = info1.split(delims2);
double lat = Double.parseDouble(tokens2[0]);
double lon = Double.parseDouble(tokens2[1]);
final String location = tokens2[0]+","+tokens2[1];
dialog1.setMessage(info2);
dialog1.setPositiveButton("Navigate", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Nav(location);
}
});
dialog1.setNegativeButton("Directions", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Direction(location);
}
}) ;
dialog1.show();
return true;
}
public void Nav(String location) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location));
mContext.startActivity(i);
}
public void Direction(String location) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + location));
mContext.startActivity(i);
}
}
nasıl ekliyorum öğeler:
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.plug);
itemizedoverlay = new Points(drawable, this);
while (...) {
point = new GeoPoint((int) (lat * 1000000), (int) (lon * 1000000));
overlayitem = new OverlayItem(point, Station_Name, comb);
itemizedoverlay.addOverlay(overlayitem);
}
Bunu denedim ve benim için daha hızlı değildi. Eklemek için 108 ürünüm vardı ve bunları üç bölüm halinde ayırdım. Kullandığım yöntemden bağımsız olarak aynı hızdaydı. – dermatthias
Evet, bu yüzden örneğimde 100 öğe kullandım. Hızın düşmeye başladığında sınırın belki 150 ürün olduğunu tahmin ediyorum, bu yüzden endişelenmenize gerek yok. –