How you declarate your class ItemizedOverlay in the Manifest ?

On 4 sep, 10:57, sweet <[email protected]> wrote:
> Thanks for your code but it not work. it's an android1.1, 1.5 or a
> Google api ?
>
> On 3 sep, 15:20, ragavendran s <[email protected]> wrote:
>
> > On Thu, Sep 3, 2009 at 1:06 PM,sweet<[email protected]> wrote:
>
> > > hello everybody !!!
> > > I make the tutorial Hellomapview (http://developer.android.com/intl/fr/
> > > guide/tutorials/views/hello-mapview.html<http://developer.android.com/intl/fr/%0Aguide/tutorials/views/hello-m...>)
> > > if anyone have made this
> > > tuto i would like he explain to me the step 4 in the last part :
>
> > > 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);
>
> > > I've well add this OverlayItem to our collection in the
> > > HelloItemizedOverlay but i don't understand how add this to the List
> > > of Overlay objects retrieved from the MapView if someone can help me ?
> > > (I share my code if you see an other mistake)
>
> > > classe map 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) {
>
> > >                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);
> > >    }
> > >        protected boolean isRouteDisplayed() {
> > >                return false;
> > >        }
>
> > > class NewItemizedOverlay java:
>
> > > import java.util.ArrayList;
> > > import android.graphics.drawable.Drawable;
> > > import com.google.android.maps.ItemizedOverlay;
> > > import com.google.android.maps.OverlayItem;
>
> > > @SuppressWarnings("unchecked")
> > > 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();
> > >        }
>
> > > }
>
> > > xml fil of map:
>
> > > <?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>
>
> > > Thanks
> > >Sweet
>
> > HelloSweetu try this code .....it  works....i got this code from same u
> > defined in the url..but i changed for  my own....u look this code it will
> > help u....and one more thing dont forget to add ur marker image in
> > res/drawable
>
> > All the Best....
>
> > package samp.sam11;
>
> > 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.MapController;
> > import com.google.android.maps.MapView;
> > import com.google.android.maps.Overlay;
> > import com.google.android.maps.OverlayItem;
>
> > import android.view.View;
> > import android.view.View.OnClickListener;
>
> > import android.app.AlertDialog;
> > import android.app.Dialog;
> > import android.graphics.drawable.Drawable;
> > import android.location.Address;
> > import android.location.Geocoder;
> > import android.os.Bundle;
> > import android.widget.Button;
> > import android.widget.EditText;
>
> > public class sam1 extends MapActivity {
>
> >     protected boolean isRouteDisplayed() {
> >         // TODO Auto-generated method stub
> >         return false;
> >     }
> >     /** Called when the activity is first created. */
>
> >     MapView mapView;
> >     EditText edt;
> >     Button bttn;
> >     Geocoder gc;
> >     double lat;
> >     double lon;
> >     List<Overlay> mapOverlays;
> >     Drawable drawable;
> >     HelloItemizedOverlay itemizedOverlay;
>
> >     @Override
> >     public void onCreate(Bundle savedInstanceState) {
> >         super.onCreate(savedInstanceState);
> >         setContentView(R.layout.main);
> >         mapView = (MapView) findViewById(R.id.mapview);
> >         edt=(EditText)findViewById(R.id.edt);
> >         bttn=(Button)findViewById(R.id.bttn);
>
> >         gc=new Geocoder(this);
> >         bttn.setOnClickListener(new OnClickListener(){
>
> >             public void onClick(View v)
> >             {
> >                 String str=edt.getText().toString();
>
> >                 try {
> >                     List<Address> loc=gc.getFromLocationName(str,7);
>
> >                     if(loc.size()!=0)
> >                     {
> >                     for(int i=0;i<loc.size();++i){
>
> >                     Address x=loc.get(i);
> >                     lat=x.getLatitude();
> >                     lon=x.getLongitude();
> >                     }
> >                     gotolocation((lat*1000000),(lon*1000000),mapView);
> >                     }
> >                     else
> >                     {
> >                         Dialog locationError = new AlertDialog.Builder(
> >                                 sam1.this).setIcon(0).setTitle(
> >                                 "Error").setPositiveButton(R.string.ok,
> > null)
> >                                 .setMessage(
> >                                         "Sorry, your address doesn't
> > exist.")
> >                                 .create();
> >                         locationError.show();
> >                     }
>
> >                 } catch (IOException e) {
> >                     // TODO Auto-generated catch block
> >                     e.printStackTrace();
> >                 }
>
> >             }
>
> >         });
>
> >     }
>
> >     public void gotolocation(double latitude,double longitude,MapView mymap)
> >     {
> >         GeoPoint p=new GeoPoint((int) latitude,(int) longitude);
> >         mapOverlays = mapView.getOverlays();
> >         drawable =
> > this.getResources().getDrawable(R.drawable.androidmarker);
> >         itemizedOverlay = new HelloItemizedOverlay(drawable);
> >         mapView.displayZoomControls(true);
> >         OverlayItem overlayitem = new OverlayItem(p, "", "");
> >         itemizedOverlay.addOverlay(overlayitem);
> >         mapOverlays.add(itemizedOverlay);
>
> >         MapController mc=mapView.getController();
> >         mc.animateTo(p);
> >         int zoomlevel=mapView.getMaxZoomLevel();
> >         mc.setZoom(zoomlevel - 1);
> >         mapView.setSatellite(false);
>
> >     }
>
> > }
>
> > Hello Itemized.java:
>
> > package samp.sam11;
>
> > import java.util.ArrayList;
>
> > import android.graphics.drawable.Drawable;
>
> > import com.google.android.maps.ItemizedOverlay;
> > import com.google.android.maps.OverlayItem;
>
> > public class HelloItemizedOverlay extends ItemizedOverlay {
>
> >     private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
>
> >     public
>
> ...
>
> plus de détails »
--~--~---------~--~----~------------~-------~--~----~
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