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.031 seconds, using GeSHi 1.0.8.4


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));
  4.                
  5.                
  6.        
  7.                 // initialize Marker
  8.                 Drawable marker = this.getResources().getDrawable(R.drawable.marker);
  9.                 marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
  10.                
  11.  
  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.032 seconds, using GeSHi 1.0.8.4


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?
cybermaid
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jun 14, 2010 11:32 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests