Listing 1012 srccomcookbookaddingmarkersMyLocationjava

package com.cookbook.adding_markers;

import java.io.IOException; import java.util.List;

import android.content.Context; import android.graphics.drawable.Drawable; import android.location.Address; import android.location.Geocoder;

import android.os.Bundle; import android.widget.TextView;

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;

public class MyLocation extends MapActivity { TextView tv;

List<0verlay> mapOverlays; MyMarkerLayer markerlayer; private MapController mc; public static Context mContext;

^Override public void onCreate(Bundle savedlnstanceState) { super.onCreate(savedlnstanceState); mContext = this; setContentView(R.layout.main);

MapView mapView = (MapView) findViewByld(R.id.mapl); tv = (TextView) findViewByld(R.id.tvl);

mapOverlays = mapView.getOverlays(); Drawable drawable =

this.getResources().getDrawable(R.drawable.icon); markerlayer = new MyMarkerLayer(drawable);

List<Address> addresses;

String myAddress="1600 Amphitheatre Parkway, Mountain View, CA";

Geocoder gc = new Geocoder(this); try {

addresses = gc.getFromLocationName(myAddress, 1); if(addresses != null) {

Address x = addresses.get(0);

geolat = (int)(x.getLatitude()*1E6); geolon = (int)(x.getLongitude()*1E6);

} catch(I0Exception e) {

tv.setText(e.getMessage());

mapView.setBuiltlnZoomControls(true); GeoPoint point = new GeoPoint(geolat,geolon); mc = mapView.getController();

mc.animateTo(point); mc.setZoom(3);

Overlayltem overlayitem =

new OverlayItem(point, "Google Campus", "I am at Google"); markerlayer.addOverlayltem(overlayitem); mapOverlays.add(markerlayer);

^Override protected boolean isRouteDisplayed() { return false; }

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook


Post a comment