Dynamic location + static objects based on first location

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Dynamic location + static objects based on first location

Postby cybermaid » Mon Jun 14, 2010 11:53 am

I'm trying to get the following working.
When the app starts it locates your position...based on that position it adds markers on the map.
All objects (including your own location marker) are overlays.
On the location changed action your marker should move...but the other markers should remain on that position.

The problem lies in this piece of code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if (listOfOverlays.size() > 0) {
  2.                         for (Iterator iterator = listOfOverlays.iterator(); iterator.hasNext();) {
  3.                                 iterator.next();
  4.                                 iterator.remove();
  5.                         }
  6.                 }
Parsed in 0.014 seconds, using GeSHi

It either removes all the overlays and redraw them on a new location (which is good for YOUR location, but not for the static markers which should be static after the starting position)
Or, when this is removed...it never removes a marker and keeps adding more overlays.

Static markers are made like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. GeoPoint Point = new GeoPoint(
  2.                 (int) (geopoint.getLatitudeE6()+400),
  3.                 (int) (geopoint.getLongitudeE6()+400));
  7.                 // initialize Marker
  8.                 Drawable marker = this.getResources().getDrawable(R.drawable.marker);
  9.                 marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
  12.                 // create overlay and show it
  13.                 Overlay markerOverlay = new Overlay(marker, this);
  14.                 OverlayItem markerItem = new OverlayItem(Point, "Marker", null);
  15.                 Overlay.addItem(markerItem);
  16.                 myMap.getOverlays().add(markerOverlay );
Parsed in 0.011 seconds, using GeSHi

So it should get the first position from where you are standing and use that once.
Or...the remove function should just remove the dynamic overlay...but how?
Once Poster
Once Poster
Posts: 1
Joined: Mon Jun 14, 2010 11:32 am


Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests