Hi, I am trying to develop an app to list the bus stops for my local Public
Transit buses on a google map map,
but i seem to be having problem loading the overlay markers locations from a
text file

Heres the code i use to load a new overlay onto the mapview:


[CODE]
    public void AddOverlayItem(int intLat, int intLong, String
strStop,String strType) {
     Toast.makeText(HelloGoogleMaps.this.getBaseContext(), intLat + "," +
intLong + "," + strStop + "," + strType,Toast.LENGTH_SHORT).show();
     // TODO Auto-generated method stub
     List<Overlay> mapOverlays = mapView.getOverlays();
     Drawable drawable = this.getResources().getDrawable(R.drawable.viva);

     if ("YRT".equals(strType)) {
     drawable = this.getResources().getDrawable(R.drawable.yrt);
     }

     HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);

     GeoPoint point = new GeoPoint(intLat,intLong);
     OverlayItem overlayitem = new OverlayItem(point, strStop, strType);

     itemizedoverlay.addOverlay(overlayitem);

     mapOverlays.add(itemizedoverlay);


    }
[/CODE]


When i call the above code from a button i click from within my app all
works fine, settings get saved and marker appears on screen:

[CODE]
    WriteSettings(HelloGoogleMaps.this,String.valueOf((int)(longitude*1E6))
+ "<>" +
                 String.valueOf((int)(latitude*1E6)) + "<>" +
                                      etStop.getText().toString() + "<>" +
"YRT");

    AddOverlayItem((int)(latitude*1E6),(int)(longitude*1E6),
                                etStop.getText().toString(),"YRT");
[/CODE]

But the problem i am having is when i call the following code at the end of
the onCreate method, my overlays do not appear:

[CODE]
    public void RefreshStops() {
     // Refreshes the list of bus stop's
     //Find the directory for the SD Card using the API
     //*Don't* hardcode "/sdcard"
     File sdcard = Environment.getExternalStorageDirectory();

     //Get the text file
     File file = new File(sdcard,LocFile);

     try {
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;

        while ((line = br.readLine()) != null) {
         String LineSplit[] = line.split("<>");
         
AddOverlayItem(Integer.parseInt(LineSplit[0]),Integer.parseInt(LineSplit[1]),LineSplit[2],
LineSplit[3]);
        }
     }
     catch (IOException e) {
        //You'll need to add proper error handling here

Toast.makeText(HelloGoogleMaps.this.getBaseContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
     }


    }
[/CODE]

Contents of file being read:
longitude<>latitude<>stopnumber<>bus-service

[CODE]
    cat BusLoc2.txt
    -79261518<>44006280<>2511<>YRT
    -79161518<>44006280<>3243<>YRT
    -79161518<>44006280<>6465<>YRT
    -79161518<>44006280<>675<>YRT
[/CODE]

I know the AddOverlayItem() method is being called from the RefreshStops()
method because i have put a 'toast' in the AddOverlayItem() method for debug
purposes and can see the info being passed to it correctly but for some
reason they are not appearing??????

Any one have any idea why my markers are not being added?
Thanks for any help

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to