title: How to show markers in Google map, latitude and lng obtained from XML URL after parsing
body: <p>I had done sax XML parsing and now I want to display that lat and lng on map using marker. I am able to display one static marker. I mean I pass lat and lng value to geo point, but how to display all points which is obtained from XML parsing?</p>
  
  <p>This question is very important to me but I am unable to do it during the last two days. I am new in Android and Java, so please help me.</p>
  
  <pre><code>public class XMLparsingExample extends MapActivity {
      String name;
      private String array_latitude[];
      private String array_longitude[];
      SitesList sitesList = null;
      private MapController mapController;
      private MapView mapView;
      private LocationManager locationManager;
      String value1;
      String value2;
      GeoPoint p;
  
      class MapOverlay extends com.google.android.maps.Overlay {
          @Override
          public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
              super.draw(canvas, mapView, shadow);
              // ---translate the GeoPoint to screen pixels---
              Point screenPts = new Point();
              mapView.getProjection().toPixels(p, screenPts);
              // ---add the marker---
              Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
              canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null);
              return true;
          }
      }
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          try {
              SAXParserFactory spf = SAXParserFactory.newInstance();
              SAXParser sp = spf.newSAXParser();
              XMLReader xr = sp.getXMLReader();
              /** Send URL to parse XML Tags */
              URL sourceUrl = new URL("http://site4demo.com/artealdiaonline/output.php?lat=-34.6394879&amp;lng=-58.3617837kkj");
              /** Create handler to handle XML Tags ( extends DefaultHandler ) */
              MyXMLHandler myXMLHandler = new MyXMLHandler();
              xr.setContentHandler(myXMLHandler);
              xr.parse(new InputSource(sourceUrl.openStream()));
          } catch (Exception e) {
              System.out.println("XML Pasing Excpetion = " + e);
          }
          /** Get result from MyXMLHandler SitlesList Object */
          sitesList = MyXMLHandler.sitesList;
          ArrayList&lt;Integer&gt; Latitude = new ArrayList&lt;Integer&gt;();
          ArrayList&lt;Integer&gt; Longtitude = new ArrayList&lt;Integer&gt;();
          RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout);
          mapView = (MapView) findViewById(R.id.mapview);
          mapView.setBuiltInZoomControls(true);
          // mapView.setStreetView(true);
          mapView.setSatellite(true);
          mapController = mapView.getController();
          mapController.setZoom(14);
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new GeoUpdateHandler());
          /*
           * how to pass here latitude and longitude getting after xml parsing for
           * displaying all lat and long in map
           */
          p = new GeoPoint((int) (32.864 * 1E6), (int) (-117.2353 * 1E6));
          mapController.animateTo(p);
          mapController.setZoom(17);
          // ---Add a location marker---
          MapOverlay mapOverlay = new MapOverlay();
          List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays();
          listOfOverlays.clear();
          listOfOverlays.add(mapOverlay);
          mapView.invalidate();
      }
  
      @Override
      protected boolean isRouteDisplayed() {
          return false;
      }
  
      public class GeoUpdateHandler implements LocationListener {
          @Override
          public void onLocationChanged(Location location) {
              int lat = (int) (location.getLatitude() * 1E6);
              int lng = (int) (location.getLongitude() * 1E6);
              GeoPoint point = new GeoPoint(lat, lng);
              mapController.animateTo(point); // mapController.setCenter(point);
          }
  
          @Override
          public void onProviderDisabled(String provider) {
          }
  
          @Override
          public void onProviderEnabled(String provider) {
          }
  
          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {
          }
      }
  }
  </code></pre>
  
  <p><strong>siteslist.java</strong>:</p>
  
  <pre><code>public class SitesList {
      /** Variables */
      private ArrayList&lt;String&gt; Latitude = new ArrayList&lt;String&gt;();
      private ArrayList&lt;String&gt; Longitude = new ArrayList&lt;String&gt;();
  
      /**
       * In Setter method default it will return arraylist change that to add
       */
      public ArrayList&lt;String&gt; getLatitude() {
          return Latitude;
      }
  
      public void setLatitude(String latitude) {
          this.Latitude.add(latitude);
      }
  
      public ArrayList&lt;String&gt; getLongitude() {
          return Longitude;
      }
  
      public void setLongitude(String longitude) {
          this.Longitude.add(longitude);
      }
  }
  </code></pre>