我已經實現了一個簡單的Google地圖,其中顯示了一個標記列表,具體取決於我擁有的列表。將圖像加載到地圖上的標記
要顯示他們,我遍歷列表和創建的每個標記,像這樣:
for (final PhotosForPlants p : photos) {
if (p.getLat() != null && p.getLon() != null && p.getLat() != 0.0 && p.getLon() != 0.0) // check for 0.0
{
if (p.getId() == currentPlantId) {
plantLocation = new LatLng(p.getLat(), p.getLon());
yellowPos = plantLocation;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(plantLocation, 35f));
Marker m = mMap.addMarker(new MarkerOptions().position(plantLocation)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));
m.setTag(p);
markers.add(m);
} else {
plantLocation = new LatLng(p.getLat(), p.getLon());
positions.add(plantLocation);
positionSave = index;
Marker m = mMap.addMarker(new MarkerOptions().position(plantLocation)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
m.setTag(p);
markers.add(m);
}
}
index++;
}
}
的而不是一個簡單的標記的圖像,我需要有一些像從我的服務器加載一個正方形的圖像,我嘗試用畢加索的,但如果我得到任何的問題做這種方式得到位,我不知道:
public void loadBitmap(String url) {
if (loadtarget == null) loadtarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// do something with the Bitmap
handleLoadedBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(this).load(url).into(loadtarget);
}
public Bitmap handleLoadedBitmap(Bitmap b) {
return b;
}
我的主要問題是,我不知道我可以retrive每個圖像加載爲特定的標記,以及如何使用我的地圖設置IP:S。
任何幫助?