Here a Post, There a Post
private Pattern regexLocation=Pattern.compile("L\\:((\\-)?[0-9]+(\\.[0-9]+)?)\\,
((\\-)?[0-9]+(\\.[0-9]+)?)");
That regular expression is ugly, but it effectively matches any string of the
form L:AAA,OOO, where AAA and OOO are floating-point numeric values.
You will also need to add imports for android.widget.AdapterView,
java.util.regex.Matcher, and java.util.regex.Pattern.
Now, when we click on a location-bearing status, StatusMap will open – you
can test this via the post you may have added from the previous tutorial,
containing your location. However, we need to add some logic to StatusMap
to unpack the latitude and longitude and center the map on that position.
Change StatusMap to look like the following:
package apt.tutorial.two;
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class StatusMap extends MapActivity {
private MapView map=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status_map);
map=(MapView)findViewById(R.id.map);
map.getController().setZoom( 17 );
double lat=getIntent().getDoubleExtra(Patchy.LATITUDE, 0 );
double lon=getIntent().getDoubleExtra(Patchy.LONGITUDE, 0 );
GeoPoint status=new GeoPoint((int)(lat*1000000.0),
(int)(lon*1000000.0));
map.getController().setCenter(status);
map.setBuiltInZoomControls(true);
}