我已经实现了一个简单的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。
任何帮助?