Closed GoogleCodeExporter closed 9 years ago
I admit I haven't looked too deeply at the overlays, but it seems that
OpenStreetMapViewItemizedOverlay is intended to be customisable. Couldn't you
achieve the same thing by just adding a bit more flexibility to the existing
code, eg by adding a Drawable to OpenStreetMapViewOverlayItem?
Or by diversifying OpenStreetMapViewOverlayItem into a text item and a drawable
item?
The point being to avoid duplicate code.
Original comment by neilboyd
on 8 Jul 2010 at 9:29
It should be possible to merge the two overlays into one. From my viewpoint,
and using Google's API as reference, the text items is the special case. It
could inherit from a general OverlayItem.
I started off inheriting from the existing ItemizedOverlay but abandoned that
because ItemizedOverlay requires resources that I won't ever need.
I agree on avoiding duplicate code. I can look more into it once I gain member
status. In the meantime, I'm using the supplied code in my own project.
Original comment by andpet@gmail.com
on 8 Jul 2010 at 10:07
Original comment by andpet@gmail.com
on 12 Jul 2010 at 12:48
Here's an alternate implementation which modifies the existing ItemizedOverlay.
It attempts to retrieve an icon from the item using getMarker(). If this is
null, then it falls back to the existing behavior of using the default icon
specified when the ItemizedOverlay is created.
Original comment by theodore...@gmail.com
on 17 Sep 2010 at 10:17
Attachments:
This patch looks fine with my superficial glance. I suggest that andpet
incorporates it since he knows more about this and he is already the owner of
this issue.
Original comment by neilboyd
on 20 Sep 2010 at 8:23
I think andpet...
http://groups.google.com/group/osmdroid/browse_thread/thread/b616c3509a34a98d#
...has pretty much approved the patch.
I'm interested in seeing this issue resolved. I'm going to check it out a bit
more and unless somebody complains I'll commit the patch.
Original comment by phr...@gmail.com
on 27 Sep 2010 at 11:59
Here is my combined patch.
I also changed the andnav Point to be BasicPoint so as to not be confused with
the android Point.
I am still testing this patch but I wanted to get your input.
Original comment by phr...@gmail.com
on 28 Sep 2010 at 5:49
Attachments:
I have committed revision 383.
The usage is something like...
[from OpenStreetMapViewer::OpenStreetMap.java::loadItems() a mechanism for
loading items from a content provider]
final ArrayList<OpenStreetMapViewOverlayItem> items = new
ArrayList<OpenStreetMapViewOverlayItem>();
Cursor cursor = this.managedQuery(IncidentSchema.EventTableSchema.CONTENT_URI,
null, null, null, null);
if (cursor == null) {
Toast.makeText(this, R.string.missing_content_provider, Toast.LENGTH_LONG);
return;
}
int counter = 100;
for (boolean more = cursor.moveToFirst(); more; more = cursor.moveToNext()) {
++counter;
long latitude = cursor.getLong(cursor
.getColumnIndex(IncidentSchema.EventTableSchema.LATITUDE));
long longitude = cursor.getLong(cursor
.getColumnIndex(IncidentSchema.EventTableSchema.LONGITUDE));
GeoPoint gpoint = new GeoPoint(latitude, longitude);
OpenStreetMapViewOverlayItem item = new OpenStreetMapViewOverlayItem("Category: "
+ counter, "Sample Description: " + counter, gpoint);
item.setMarker(this.getResources().getDrawable(R.drawable.brand_icon));
item.setMarkerHotspotPlace(null);
items.add(item);
}
this.mIncidentOverlay = new
OpenStreetMapViewItemizedOverlay<OpenStreetMapViewOverlayItem>(
this, items, mOnItemTapListener);
---------
I'm working on a sample using a content provider.
I'll commit that as a separate example when it is done.
Original comment by phr...@gmail.com
on 28 Sep 2010 at 8:50
You forgot to check in org.andnav.osm.util.BasicPoint
Original comment by neilboyd
on 29 Sep 2010 at 7:59
You could also delete org.andnav.osm.util.Point since it's not used any more.
Original comment by neilboyd
on 29 Sep 2010 at 8:01
Corrected by revision 386.
Original comment by phr...@gmail.com
on 30 Sep 2010 at 5:20
Or why not just use android.graphics.Point instead of BasicPoint as you did in
some other places?
Original comment by neilboyd
on 30 Sep 2010 at 6:45
Original issue reported on code.google.com by
andpet@gmail.com
on 7 Jul 2010 at 8:47Attachments: