0
我試着用1800自定義標記圖標(位圖和文本視圖)創建地圖。我出現內存錯誤,因爲我的應用程序在創建一些標記後關閉。 我該怎麼做? 這裏是我的代碼我的代碼部分: 感謝所有再見如何添加2K標記與自定義位圖圖標android v2地圖
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE)
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.getUiSettings().setRotateGesturesEnabled(true);
mMap.getUiSettings().setScrollGesturesEnabled(true);
mMap.getUiSettings().setTiltGesturesEnabled(true);
mMap.getUiSettings().setZoomGesturesEnabled(true);
mMap.setMyLocationEnabled(true);
start();
}
public void start() {
new BackgroundTask().execute();
}
private class BackgroundTask extends AsyncTask<Void, Integer, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
progress.setProgress(0);
progress.setMessage("Loading");
progress.show();
cursor.moveToFirst();
}
@Override
protected String doInBackground(Void... arg0) {
try {
if (cursor.moveToFirst())
{
do {
nome = cursor.getString(cursor.getColumnIndex(LocalDbManage.KEY_NOME));
lati = cursor.getString(cursor.getColumnIndex(LocalDbManage.KEY_LATI));
longi = cursor.getString(cursor.getColumnIndex(LocalDbManage.KEY_LONGI));
prezzo = "€ "+cursor.getString(cursor.getColumnIndex(LocalDbManage.KEY_PREZZO));
id = cursor.getString(cursor.getColumnIndex(LocalDbManage.KEY_CONTACTID));
final double latitude = Double.parseDouble(lati);
final double longitude = Double.parseDouble(longi);
iconFactory.setRotation(90);
iconFactory.setStyle(IconGenerator.STYLE_ORANGE);
addIcon(iconFactory, prezzo, new LatLng(latitude, longitude));
runOnUiThread(new Runnable() {
@Override
public void run() {
final MarkerOptions markerOptions = new MarkerOptions().
icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon())).
position(new LatLng(latitude, longitude)).
anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());
mMap.addMarker(markerOptions);
}
});
} while (cursor.moveToNext());
} else
{
System.out.println("ERROR"); // viene eseguito l'else
}
Thread.sleep(1200);
} catch (InterruptedException e) {
}
return "Lavoro Terminato!";
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
progress.dismiss();
}
}
private void addIcon(IconGenerator iconFactory,String text, LatLng position) {
MarkerOptions markerOptions = new MarkerOptions().
icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon())).
position(position).
anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV())`
}
編輯:現在我想趁自己「無法位圖拷貝到包裹的blob」我不知道這意味着什麼..請幫幫我! 感謝的
你需要擴大應答,並與相應的代碼更新發布,而不是鏈接 – Prasad