Hello there,
I have a problem that I am not able to show the name of the marker on
google map.
Actually I am making the application in which we show multiple marker,
but my problem is that I have to show place name also at that marker
point.
To achieve this I did coding in such a way
public class HelloItemizedOverLay extends ItemizedOverlay {
private ArrayList<OverlayItem> overlayItem = new ArrayList<OverlayItem>
();
public HelloItemizedOverLay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
@Override
protected OverlayItem createItem(int i) {
return overlayItem.get(i);
}
@Override
public int size() {
return overlayItem.size();
}
public void addOverlay(OverlayItem overlay) {
overlayItem.add(overlay);
populate();
}
}
and in this I add multiple OverlayItem by this way
boolean flag = false;
for (int i = 0; i < size; i++) {
if (null == place)
continue;
double lat = Double.parseDouble(xx.getLatitude());
double lon = Double.parseDouble(xx.getLongitude());
GeoPoint point = new GeoPoint(((int) (lat * 1E6)), ((int)
(lon * 1E6)));
if (!flag) {
controller.setCenter(point);
flag = true;
}
String name = "Hello" + i;
OverlayItem overlayItem = new OverlayItem(point, name,
name);
itemizedOverlay.addOverlay(overlayItem);
mOverlays.add(itemizedOverlay);
}
But it is not showing the marker
Then I tried using motion event in the class HelloItemizedOverLay
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
if (event.getAction() == MotionEvent.ACTION_UP) {
GeoPoint p = mapView.getProjection().fromPixels((int)
event.getX(), (int) event.getY());
Iterator<OverlayItem> iterator = overlayItem.iterator();
if (Logger.ENABLE_CONSOLE_DEBUG) {
Logger.printMessage(this.getClass().getSimpleName() +
"--OnTouchEvent() -- Point found " + p.getLatitudeE6() + " " +
p.getLongitudeE6(), Logger.INFO);
}
while (iterator.hasNext()) {
OverlayItem item = iterator.next();
GeoPoint gp = item.getPoint();
if (gp.getLatitudeE6() == p.getLatitudeE6() &&
gp.getLongitudeE6() == p.getLongitudeE6()) {
Toast.makeText(context, item.getTitle(),
Toast.LENGTH_SHORT).show();
}
}
}
return false;
}
But looks like that toast will only be shown when user click on the
exact pixel.
What I want that when user touch the marker drawable toast should be
shown.
Can anyone help me to do this.
Vishal
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en