위 사이트를 참고했다.
패키지명 아래에 클래스 네임으로 자바파일을 걍 만들면 된다.
package com.paxmodept.test;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.Toast;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
public class mapItemizedOverlay extends ItemizedOverlay {
private Context mContext;
private ArrayList<OverlayItem> mOverlays
= new ArrayList<OverlayItem>();
public mapItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
// TODO Auto-generated constructor stub
mContext = context;
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return mOverlays.get(i);
}
@Override
public int size() {
// TODO Auto-generated method stub
return mOverlays.size();
}
public void addOverlay(OverlayItem overlay)
{
mOverlays.add(overlay);
populate();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
Toast.makeText
(mContext, item.getSnippet(), Toast.LENGTH_LONG).show();
return true;
}
}
=============================================================================================
import com.google.android.maps.OverlayItem;
import android.graphics.drawable.Drawable;
적용은 mc(map control) 생성후
mc = mapView.getController();
String coordinates[] = {"37.5589099", "126.9444183"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));
String coordinates2[] = {"37.557465", "126.9463232"};
double lat2 = Double.parseDouble(coordinates2[0]);
double lng2 = Double.parseDouble(coordinates2[1]);
p2 = new GeoPoint(
(int) (lat2 * 1E6),
(int) (lng2 * 1E6));
mc.animateTo(p);
mc.setZoom(17);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.marker);
itemizedOverlay = new mapItemizedOverlay(drawable, this);
OverlayItem overlayitem1 =
new OverlayItem(new GeoPoint(p), "창이름","설명");
OverlayItem overlayitem2 =
new OverlayItem(new GeoPoint(p2), "창이름","설명");
itemizedOverlay.addOverlay(overlayitem1);
itemizedOverlay.addOverlay(overlayitem2);
mapOverlays.add(itemizedOverlay);
위와 같이 하면 된다. 버전에 따라 다르게 나오는 듯 하다.
댓글 달기