diff --git a/AndroidApp/HelloMapView/gen/com/barryku/android/hellomap/R.java b/AndroidApp/HelloMapView/gen/com/barryku/android/hellomap/R.java
index 6c40d03..5216b7a 100644
--- a/AndroidApp/HelloMapView/gen/com/barryku/android/hellomap/R.java
+++ b/AndroidApp/HelloMapView/gen/com/barryku/android/hellomap/R.java
@@ -23,7 +23,7 @@ public static final class id {
public static final int transparent_panel=0x7f050000;
}
public static final class layout {
- public static final int baloon=0x7f030000;
+ public static final int balloon=0x7f030000;
public static final int main=0x7f030001;
}
public static final class string {
diff --git a/AndroidApp/HelloMapView/pom.xml b/AndroidApp/HelloMapView/pom.xml
index 0b418a0..7a019b1 100755
--- a/AndroidApp/HelloMapView/pom.xml
+++ b/AndroidApp/HelloMapView/pom.xml
@@ -15,7 +15,7 @@
/home/barry/dev/android/market/android-key.keystore
- emulator
+ usb
${sdk.win}
${keystore.win}
diff --git a/AndroidApp/HelloMapView/res/layout/baloon.xml b/AndroidApp/HelloMapView/res/layout/balloon.xml
similarity index 92%
rename from AndroidApp/HelloMapView/res/layout/baloon.xml
rename to AndroidApp/HelloMapView/res/layout/balloon.xml
index eadd4ce..92acf2a 100644
--- a/AndroidApp/HelloMapView/res/layout/baloon.xml
+++ b/AndroidApp/HelloMapView/res/layout/balloon.xml
@@ -1,5 +1,5 @@
-
-
+
diff --git a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BaloonLayout.java b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BalloonLayout.java
similarity index 91%
rename from AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BaloonLayout.java
rename to AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BalloonLayout.java
index 2ed516b..487fe95 100644
--- a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BaloonLayout.java
+++ b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/BalloonLayout.java
@@ -8,11 +8,11 @@
import android.util.AttributeSet;
import android.widget.LinearLayout;
-public class BaloonLayout extends LinearLayout {
+public class BalloonLayout extends LinearLayout {
- public BaloonLayout(Context context, AttributeSet attrs) {
+ public BalloonLayout(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
diff --git a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloItemizedOverlay.java b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloItemizedOverlay.java
index c2a18f3..45753b0 100644
--- a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloItemizedOverlay.java
+++ b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloItemizedOverlay.java
@@ -37,7 +37,7 @@ public void addOverlay(OverlayItem overlay) {
@Override
public boolean onTap(GeoPoint point, MapView view) {
Log.d(LOG_TAG, "onTap point/view: " + point + "," + view);
- parent.removeBaloonTip();
+ parent.removeBalloonTip();
return super.onTap(point, view);
}
diff --git a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloMapViewActivity.java b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloMapViewActivity.java
index 64eb795..116e648 100644
--- a/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloMapViewActivity.java
+++ b/AndroidApp/HelloMapView/src/com/barryku/android/hellomap/HelloMapViewActivity.java
@@ -42,7 +42,7 @@ public class HelloMapViewActivity extends MapActivity {
private List mapOverlays;
private Drawable drawable;
private HelloItemizedOverlay itemizedOverlay;
- private BaloonLayout noteBaloon;
+ private BalloonLayout noteBalloon;
/** Called when the activity is first created. */
@Override
@@ -50,7 +50,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- setupBaloonLayout();
+ setupBalloonLayout();
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
@@ -58,8 +58,8 @@ public void onCreate(Bundle savedInstanceState) {
itemizedOverlay = new HelloItemizedOverlay(this, drawable);
try {
- setupKmlOverlays();
- //setupJsonOverlays();
+ //setupKmlOverlays();
+ setupJsonOverlays();
mapOverlays.add(itemizedOverlay);
adjustMapZoomCenter();
} catch (Exception e) {
@@ -100,7 +100,7 @@ private void setupKmlOverlays() throws Exception {
KmlRoot kml = serializer.read(KmlRoot.class, is);
List markers = kml.getDocument().getPlacemarks();
for (Placemark marker: markers) {
- point = getGeoPoint(marker.getCoordinates());
+ point = getGeoPointFromCoordiate(marker.getCoordinates());
Log.d(LOG_TAG, marker.getName());
itemizedOverlay.addOverlay(new OverlayItem(point, marker.getName(), marker.getDescription()));
}
@@ -138,19 +138,11 @@ private void setupJsonOverlays() throws Exception {
}
- private void setupBaloonLayout() {
+ private void setupBalloonLayout() {
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
- noteBaloon = (BaloonLayout) layoutInflater.inflate(R.layout.baloon, null);
-
- /**
- RelativeLayout.LayoutParams layoutParams = new
- RelativeLayout.LayoutParams(200,200);
- layoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
- layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- noteBaloon.setLayoutParams(layoutParams);
- **/
-
- TextView title = (TextView) noteBaloon.findViewById(R.id.note_txt);
+ noteBalloon = (BalloonLayout) layoutInflater.inflate(R.layout.balloon, null);
+
+ TextView title = (TextView) noteBalloon.findViewById(R.id.note_txt);
title.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
@@ -159,7 +151,7 @@ public void onClick(View v) {
});
- ImageView goButton = (ImageView) noteBaloon.findViewById(R.id.go_button);
+ ImageView goButton = (ImageView) noteBalloon.findViewById(R.id.go_button);
goButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
@@ -169,21 +161,8 @@ public void onClick(View v) {
});
}
- private int placeUrlIndex;
- public void setPlaceUrlIndex(int index) {
- placeUrlIndex = index;
- }
-
- private void goPlace() {
- if (placeUrlMap != null) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(placeUrlMap.get(placeUrlIndex)));
- startActivity(intent);
- } else {
- removeBaloonTip();
- }
- }
-
- private GeoPoint getGeoPoint(String coordinate) {
+
+ private GeoPoint getGeoPointFromCoordiate(String coordinate) {
StringTokenizer st = new StringTokenizer(coordinate, ",");
float lo = Float.parseFloat(st.nextToken());
float la = Float.parseFloat(st.nextToken());
@@ -194,17 +173,32 @@ private GeoPoint getGeoPoint(String coordinate) {
protected boolean isRouteDisplayed() {
return false;
}
-
+
+ private void goPlace() {
+ if (placeUrlMap != null) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(placeUrlMap.get(placeUrlIndex)));
+ startActivity(intent);
+ } else {
+ removeBalloonTip();
+ }
+ }
+
+ //the following methods are called by HelloItemizedOverlay.onTap();
+ private int placeUrlIndex;
+ public void setPlaceUrlIndex(int index) {
+ placeUrlIndex = index;
+ }
+
public void doTap(OverlayItem noteOverlay, String txt) {
- mapView.removeView(noteBaloon);
- noteBaloon.setVisibility(View.VISIBLE);
- ((TextView)noteBaloon.findViewById(R.id.note_txt)).setText(txt);
+ mapView.removeView(noteBalloon);
+ noteBalloon.setVisibility(View.VISIBLE);
+ ((TextView)noteBalloon.findViewById(R.id.note_txt)).setText(txt);
MapController mapController = mapView.getController();
mapController.animateTo(noteOverlay.getPoint());
- mapView.addView(noteBaloon, new MapView.LayoutParams(12*txt.getBytes().length,55,noteOverlay.getPoint(),MapView.LayoutParams.BOTTOM_CENTER));
+ mapView.addView(noteBalloon, new MapView.LayoutParams(12*txt.getBytes().length,55,noteOverlay.getPoint(),MapView.LayoutParams.BOTTOM_CENTER));
}
- public void removeBaloonTip() {
- noteBaloon.setVisibility(View.GONE);
+ public void removeBalloonTip() {
+ noteBalloon.setVisibility(View.GONE);
}
}
\ No newline at end of file