MapView with itemizedOverlay still don't work

by sweet » Mon, 07 Sep 2009 16:35:52 GMT


Sponsored Links
 've try to make a mapview with itemized overlay and it's not work.
I share my code if anyone see anything :

java class mapview:

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;
}

java ItemizedOverlay class:

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();
}

}

xml mapview 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="0G***********************************fwcg"/>
<LinearLayout
android:id="@+id/zoomview"
android:layout_width="wrap_content"
android:layout_height="wrap_content&quo



MapView with itemizedOverlay still don't work

by Nicholas Albion » Tue, 08 Sep 2009 08:00:02 GMT


 ou need to call:
mapOverlays.add( itemizedOverlay );

also, if you're adding/removing overlay items to/from ItemizedOverlay,
you may need to call setLastFocusedIndex(-1) (or whatever the method
is). I think in your case you won't need to worry with this as you
only call "addOverlay" and "populate" once.

On Sep 7, 6:34pm, sweet <brou...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Vector Graphics Rendering - Mechanisms

Hi All,

I need to render SVG SMIL animations on an android device and I know
that SVG is not supported till Android 2.2
So I am looking for alternative ways to display my SVG SMIL file

Can anyone help me with how I can process the SVG file to convert it
into some other 2d graphics rendering apis to display the animations ?

Do I need to convert my SVG file into opengl apis to render the
graphics or is there a way to create the SVG into some kind of pixel
buffer every animation interval

Thanks in Advance

Regards
Raks

-- 

2. Recent Apps change in 2.2 - Brings main Activity to foreground, not the last visible one

The recent apps display seems to function quite differently from
earlier versions on 2.2.

Try the following for instance:
1) Open an app
2) Click on something that takes you to another activity in the same
app
3) Press the home button
4) Press and hold the home button to get the recent list of apps -
select the app you chose in step 1
5) You'll be taken to whatever activity in that app is specified as
the main/launcher Activity, rather than the Activity on top of the
stack (as it was previously)

It makes it appear to the user that the application has exited when
the home screen button was pressed.

I don't have my app set to clear history on launch or anything like
that, and I can replicate it on the emulator and with any app on my
device (Contacts, Gmail, Engadget etc)

Anyone else notice this? Anyone know any reason for the changes? I
must admit I quite dislike the new method.

-- 

3. SQLiteOpenHelper per activity??

4. How to override the <ENTER> key behaviour of the virtual keyboard in Android

5. java.lang.IllegalStateException: Content has been consumed

6. R cannot be resolved

7. How could I avoid others to get my used pictures in my application?