i dont know if you meaning to the last lines of the tutorial
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
that code does not go in HelloItemizedOverlay.java but in the Activity
class
HelloViewMap.java<?ui=2&ik=1f4971b240&view=att&th=1235183b6e514f3e&attid=0.1&disp=attd>
2009/8/22 John Pszeniczny <[email protected]>
>
> Hi, I'm running into a snag on the last step (Step 4) of the Hello Map
> Views Tutorial. Where does this code go in HelloItemizedOverlay.java
>
> 4. All that's left is for us to add this OverlayItem to our collection
> in the HelloItemizedOverlay, and add this to the List of Overlay
> objects retrieved from the MapView:
>
> itemizedoverlay.addOverlay(overlayitem);
> mapOverlays.add(itemizedoverlay);
>
> Thanks in advance, I'm such a newb!
>
> John
>
> >
>
--
Atte
[[Jose Luis Ayerdis Espinoza]]
http://blognecronet.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---
package android.google.example;
import java.io.IOException;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.ZoomControls;
public class HelloViewMap extends MapActivity {
/** Called when the activity is first created. */
private LinearLayout linearLayout;
private MapView mapView;
private ZoomControls zoomController;
private List<Overlay> mapOverlays;
private Drawable drawable;
private HelloItemizedOverlay itemizedOverlay;
@Override
protected boolean isRouteDisplayed(){
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
linearLayout = (LinearLayout) findViewById(R.id.zoomview);
mapView = (MapView) findViewById(R.id.mapview);
zoomController = (ZoomControls) mapView.getZoomControls();
linearLayout.addView(zoomController);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.icon1);
itemizedOverlay = new HelloItemizedOverlay(drawable);
LocationManager manager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location= manager.getLastKnownLocation(manager.getBestProvider(new Criteria(),true));
double latitude=location.getLatitude()*1E6;
double longitude=location.getLongitude()*1E6;
Geocoder geoCoder=new Geocoder(this);
Address address;
try {
address = (Address)geoCoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1).get(0);
if(null!=address.getCountryName())
Log.i("Country: ",address.getCountryName());
if(null!=address.getSubAdminArea())
Log.i("Subadmin: ",address.getSubAdminArea());
if(null!=address.getLocality())
Log.i("Locality: ",address.getLocality());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
GeoPoint point2 = new GeoPoint((int)latitude,(int)longitude);
OverlayItem overlayitem = new OverlayItem(point2, "Other", "");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
}
}