Thanks jed for your help it's near good ^^
I've the mapview but not any ItemizedOverlay
I really think i've an error in may NewItemizedOverlay class but i
can't fiind it ...
NewItemizedOverlay class java:
import java.util.ArrayList;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
public class NewItemizedOverlay extends ItemizedOverlay {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>
();
public NewItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
// TODO Auto-generated constructor stub
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
}
(I share the other part of code but i don't think the mistake is here)
map class java :
import java.util.List;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.ZoomControls;
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;
public class Map extends MapActivity {
List<Overlay> mapOverlays;
Drawable drawable;
NewItemizedOverlay itemizedOverlay;
LinearLayout linearLayout;
MapView mapView;
ZoomControls mZoom;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable
(R.drawable.androidmarker);
itemizedOverlay = new NewItemizedOverlay(drawable);
GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "", "");
itemizedOverlay.addOverlay(overlayitem);
}
protected boolean isRouteDisplayed() {
return false;
}
map Xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0GWRUwsy0_POHxdWofVfhZeFLwtgkcn7ouMfwcg"/>
<LinearLayout
android:id="@+id/zoomview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/mapview"
android:layout_centerHorizontal="true"/>
</LinearLayout>
If you see an error ...
Thanks a lot for your help guys.
Sweet
On 3 sep, 22:43, Jed <[email protected]> wrote:
> On Sep 3, 12:36 am,sweet<[email protected]> wrote:
>
> > 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);
>
> It looks to me like you have a few errors in onCreate(). You are
> trying to add an OverlayItem to your ItemizedOverlay before you
> instatiate the ItemizedOverlay. And you also try adding that overlay
> to the list of overlays before you get the list of overlays you want
> to add it to.
>
>
>
> > @Override
> > public void onCreate(Bundle savedInstanceState) {
>
> > GeoPoint point = new GeoPoint(19240000,-99120000);
> > OverlayItem overlayitem = new OverlayItem(point, "", "");
> > itemizedOverlay.addOverlay(overlayitem);
> > mapOverlays.add(itemizedOverlay);
> > mapOverlays = mapView.getOverlays();
> > drawable = this.getResources().getDrawable
> > (R.drawable.androidmarker);
> > itemizedOverlay = new NewItemizedOverlay(drawable);
>
> > super.onCreate(savedInstanceState);
> > setContentView(R.layout.map);
> > linearLayout = (LinearLayout) findViewById(R.id.zoomview);
> > mapView = (MapView) findViewById(R.id.mapview);
> > mapView.setBuiltInZoomControls(true);
> > mapView.setSatellite(true);
> > }
>
> This is all out of order. You need to initialize your variables before
> you try to use them.
> Try this in your onCreate():
>
> super.onCreate(savedInstanceState);
> setContentView(R.layout.map);
> mapView = (MapView) findViewById(R.id.mapview);
> mapView.setBuiltInZoomControls(true);
> mapView.setSatellite(true);
>
> mapOverlays = mapView.getOverlays();
>
> drawable = this.getResources().getDrawable(R.drawable.androidmarker);
> itemizedOverlay = new NewItemizedOverlay(drawable);
>
> GeoPoint point = new GeoPoint(19240000,-99120000);
> OverlayItem overlayitem = new OverlayItem(point, "", "");
> itemizedOverlay.addOverlay(overlayitem);
>
> Hope that helps!
> Jed
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---