Skip to content

Commit

Permalink
renamed baloon to balloon
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry@Work authored and Barry@Work committed Jul 13, 2011
1 parent 243c3dd commit 3c73914
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
Expand Up @@ -23,7 +23,7 @@ public static final class id {
public static final int transparent_panel=0x7f050000; public static final int transparent_panel=0x7f050000;
} }
public static final class layout { 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 int main=0x7f030001;
} }
public static final class string { public static final class string {
Expand Down
2 changes: 1 addition & 1 deletion AndroidApp/HelloMapView/pom.xml
Expand Up @@ -15,7 +15,7 @@
<keystore.linux>/home/barry/dev/android/market/android-key.keystore</keystore.linux> <keystore.linux>/home/barry/dev/android/market/android-key.keystore</keystore.linux>


<!-- change the following for Linux vs. Windows --> <!-- change the following for Linux vs. Windows -->
<target.device>emulator</target.device> <target.device>usb</target.device>
<sdk>${sdk.win}</sdk> <sdk>${sdk.win}</sdk>
<keystore>${keystore.win}</keystore> <keystore>${keystore.win}</keystore>


Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.barryku.android.hellomap.BaloonLayout <com.barryku.android.hellomap.BalloonLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/transparent_panel" android:id="@+id/transparent_panel"
android:layout_width="fill_parent" android:layout_width="fill_parent"
Expand Down Expand Up @@ -29,5 +29,5 @@
android:clickable="true" android:clickable="true"
/> />
</RelativeLayout> </RelativeLayout>
</com.barryku.android.hellomap.BaloonLayout> </com.barryku.android.hellomap.BalloonLayout>


Expand Up @@ -8,11 +8,11 @@
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.LinearLayout; 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); super(context, attrs);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
Expand Down
Expand Up @@ -37,7 +37,7 @@ public void addOverlay(OverlayItem overlay) {
@Override @Override
public boolean onTap(GeoPoint point, MapView view) { public boolean onTap(GeoPoint point, MapView view) {
Log.d(LOG_TAG, "onTap point/view: " + point + "," + view); Log.d(LOG_TAG, "onTap point/view: " + point + "," + view);
parent.removeBaloonTip(); parent.removeBalloonTip();
return super.onTap(point, view); return super.onTap(point, view);
} }


Expand Down
Expand Up @@ -42,24 +42,24 @@ public class HelloMapViewActivity extends MapActivity {
private List<Overlay> mapOverlays; private List<Overlay> mapOverlays;
private Drawable drawable; private Drawable drawable;
private HelloItemizedOverlay itemizedOverlay; private HelloItemizedOverlay itemizedOverlay;
private BaloonLayout noteBaloon; private BalloonLayout noteBalloon;


/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);


setupBaloonLayout(); setupBalloonLayout();
mapView = (MapView) findViewById(R.id.mapview); mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true); mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays(); mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.androidmarker); drawable = this.getResources().getDrawable(R.drawable.androidmarker);
itemizedOverlay = new HelloItemizedOverlay(this, drawable); itemizedOverlay = new HelloItemizedOverlay(this, drawable);


try { try {
setupKmlOverlays(); //setupKmlOverlays();
//setupJsonOverlays(); setupJsonOverlays();
mapOverlays.add(itemizedOverlay); mapOverlays.add(itemizedOverlay);
adjustMapZoomCenter(); adjustMapZoomCenter();
} catch (Exception e) { } catch (Exception e) {
Expand Down Expand Up @@ -100,7 +100,7 @@ private void setupKmlOverlays() throws Exception {
KmlRoot kml = serializer.read(KmlRoot.class, is); KmlRoot kml = serializer.read(KmlRoot.class, is);
List<Placemark> markers = kml.getDocument().getPlacemarks(); List<Placemark> markers = kml.getDocument().getPlacemarks();
for (Placemark marker: markers) { for (Placemark marker: markers) {
point = getGeoPoint(marker.getCoordinates()); point = getGeoPointFromCoordiate(marker.getCoordinates());
Log.d(LOG_TAG, marker.getName()); Log.d(LOG_TAG, marker.getName());
itemizedOverlay.addOverlay(new OverlayItem(point, marker.getName(), marker.getDescription())); itemizedOverlay.addOverlay(new OverlayItem(point, marker.getName(), marker.getDescription()));
} }
Expand Down Expand Up @@ -138,19 +138,11 @@ private void setupJsonOverlays() throws Exception {


} }


private void setupBaloonLayout() { private void setupBalloonLayout() {
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
noteBaloon = (BaloonLayout) layoutInflater.inflate(R.layout.baloon, null); noteBalloon = (BalloonLayout) layoutInflater.inflate(R.layout.balloon, null);


/** TextView title = (TextView) noteBalloon.findViewById(R.id.note_txt);
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);
title.setOnClickListener(new OnClickListener() { title.setOnClickListener(new OnClickListener() {


public void onClick(View v) { public void onClick(View v) {
Expand All @@ -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() { goButton.setOnClickListener(new OnClickListener() {


public void onClick(View v) { public void onClick(View v) {
Expand All @@ -169,21 +161,8 @@ public void onClick(View v) {
}); });
} }


private int placeUrlIndex;
public void setPlaceUrlIndex(int index) { private GeoPoint getGeoPointFromCoordiate(String coordinate) {
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) {
StringTokenizer st = new StringTokenizer(coordinate, ","); StringTokenizer st = new StringTokenizer(coordinate, ",");
float lo = Float.parseFloat(st.nextToken()); float lo = Float.parseFloat(st.nextToken());
float la = Float.parseFloat(st.nextToken()); float la = Float.parseFloat(st.nextToken());
Expand All @@ -194,17 +173,32 @@ private GeoPoint getGeoPoint(String coordinate) {
protected boolean isRouteDisplayed() { protected boolean isRouteDisplayed() {
return false; 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) { public void doTap(OverlayItem noteOverlay, String txt) {
mapView.removeView(noteBaloon); mapView.removeView(noteBalloon);
noteBaloon.setVisibility(View.VISIBLE); noteBalloon.setVisibility(View.VISIBLE);
((TextView)noteBaloon.findViewById(R.id.note_txt)).setText(txt); ((TextView)noteBalloon.findViewById(R.id.note_txt)).setText(txt);
MapController mapController = mapView.getController(); MapController mapController = mapView.getController();
mapController.animateTo(noteOverlay.getPoint()); 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() { public void removeBalloonTip() {
noteBaloon.setVisibility(View.GONE); noteBalloon.setVisibility(View.GONE);
} }
} }

0 comments on commit 3c73914

Please sign in to comment.