Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3673244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:42:32+00:00 2026-05-19T02:42:32+00:00

I had it working until i tried to combine it with xml that is

  • 0

I had it working until i tried to combine it with xml that is parsed from my webpage. No markers get added, yet i get no errors. Below is the new code. Any help is greatly appreciated!

LocationBasedServicesV2.java :

private MapView myMap;
private TextView tv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tv = (TextView) findViewById(R.id.tv);
    try {
           URL url = new URL("MySiteGoesHere");
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            ExampleHandler myExampleHandler = new ExampleHandler();
            xr.setContentHandler(myExampleHandler);
            xr.parse(new InputSource(url.openStream()));
            ParsedExampleDataSet parsedExampleDataSet = myExampleHandler.getParsedData();
            tv.setText(parsedExampleDataSet.toString());
    } catch (Exception e) {
        new AlertDialog.Builder(this)   
        .setMessage(e.toString())   
        .setTitle("error")   
        .setCancelable(true)   
        .setNeutralButton(android.R.string.cancel,   
           new DialogInterface.OnClickListener() {   
           public void onClick(DialogInterface dialog, int whichButton){}   
           })   
        .show(); 
    }


    initMap();
    //initLocationManager();
}
private void initMap() {
    myMap = (MapView) findViewById(R.id.mymap);

    View zoomView = myMap.getZoomControls();
    LinearLayout myzoom = (LinearLayout) findViewById(R.id.myzoom);
    myzoom.addView(zoomView);
    myMap.displayZoomControls(true);

}
/*private void initLocationManager() {
    locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locListener = new LocationListener() {
        public void onLocationChanged(Location newLocation) {
            createAndShowMyItemizedOverlay(newLocation);
        }
        public void onProviderDisabled(String arg0) {
        }
        public void onProviderEnabled(String arg0) {
        }
        public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        }
    };
    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
            locListener);
}*/
public void createAndShowMyItemizedOverlay(int Lat,int Long) {
    //int Lat2;
    //int Long2;
    //Lat2 = Integer.parseInt(Lat);
    //Long2 = Integer.parseInt(Long);
    List overlays = myMap.getOverlays();
    GeoPoint geopoint = new GeoPoint(Lat,Long);
    Drawable icon = getResources().getDrawable(R.drawable.icon);
    icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon
            .getIntrinsicHeight());
    MyItemizedOverlay overlay = new MyItemizedOverlay(icon);
    OverlayItem item = new OverlayItem(geopoint, "My Location", null);
    overlay.addItem(item);
    myMap.getOverlays().add(overlay);
    myMap.getController().animateTo(geopoint);

        }
@Override
protected boolean isRouteDisplayed() {
    return false;
}
 }

MyItemizedOverlay.java:

 public class MyItemizedOverlay extends ItemizedOverlay {
private List items;
private Drawable marker;
public MyItemizedOverlay(Drawable defaultMarker) {
    super(defaultMarker);
    items = new ArrayList();
    marker = defaultMarker;
}
@Override
protected OverlayItem createItem(int index) {
    return (OverlayItem)items.get(index);
}
@Override
public int size() {
    return items.size();
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);
    boundCenterBottom(marker);
}
public void addItem(OverlayItem item) {
    items.add(item);
    populate();
}
 }

ExampleHandler.java:

public class ExampleHandler extends DefaultHandler{

    private boolean in_lat = false;
    private boolean in_long = false;
    private boolean in_retailer = false;

    private ParsedExampleDataSet myParsedExampleDataSet = new ParsedExampleDataSet();


    public ParsedExampleDataSet getParsedData() {
            return this.myParsedExampleDataSet;
    }

    @Override
    public void startDocument() throws SAXException {
            this.myParsedExampleDataSet = new ParsedExampleDataSet();
    }

    @Override
    public void endDocument() throws SAXException {
            // Nothing to do
    }


    @Override
    public void startElement(String namespaceURI, String localName,
                    String qName, Attributes atts) throws SAXException {
            if (localName.equals("Lat")) {
                    this.in_lat = true;
            }else if (localName.equals("Long")) {
                this.in_long = true;
            }

    }


    @Override
    public void endElement(String namespaceURI, String localName, String qName)
                    throws SAXException {
           if (localName.equals("Lat")) {
                    this.in_lat = false;
            }else if (localName.equals("Long")) {
                this.in_long = false;}
            else if (localName.equals("Retailer")) {
                this.in_retailer = false;}
    }

    @Override
    public void characters(char ch[], int start, int length) {
            if(this.in_lat){
            myParsedExampleDataSet.setExtractedString(new String(ch, start, length));}
            else if(this.in_long){
                myParsedExampleDataSet.setExtractedString2(new String(ch, start,     length));}

}
}

ParsedExampleDataSet.Java:

public class ParsedExampleDataSet extends LocationBasedServicesV2 {
private String extractedString = null;
private String OLDextractedString = null;
String Long;
String Lat;
Double Long2;
Double Lat2;
int Lat3;
int Long3;

public void setExtractedString(String extractedString) {
        Long = extractedString;
        Long2 = Double.parseDouble(Long);
        Long3 =  (int) (Long2 * 1E6);
        /*if (OLDextractedString != null){
        this.extractedString = OLDextractedString + extractedString + ',' ; 
    }
    else
    {
        this.extractedString = extractedString + ',' ;
    }
        OLDextractedString = this.extractedString;*/
}
public void setExtractedString2(String extractedString) {
   Lat = extractedString;
   Lat2 = Double.parseDouble(Lat);
   Lat3 =  (int) (Lat2 * 1E6);
   createAndShowMyItemizedOverlay(Lat3,Long3);
   /*if (OLDextractedString != null){
     * 
        this.extractedString = OLDextractedString + extractedString + '\n' ;    
    }
    else
    {
        this.extractedString = OLDextractedString + '\n' + extractedString  ;
    }
    OLDextractedString = this.extractedString;*/
}
   public int parseInt(){

       return Lat3;

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:42:32+00:00Added an answer on May 19, 2026 at 2:42 am

    One thing to check: your method createAndShowMyItemizedOverlay() appears to be only called when the ParsedExampleDataSet is created – and this is created in a try/catch where you’re swallowing any exception. This could be the reason why your not seeing an error and why it stopped working when you started trying to parse the xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a
I had a parametrized insert statement that was working well and I needed to
I was working on some code recently and came across a method that had
Greetings! I'm working on wrapping my head around LINQ. If I had some XML
I'm currently working on a project were I had to wrap the C++ classes
I am working on a little Perl module and for some reason I had
I'm currently developing application using DirectSound for communication on an intranet. I've had working
I've got an android app that authenticates to an appengine app. I've had it
I thought I had this all figured out, but now that I'm writing a
I'm working on a client/server application where the connections from the client to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.