Issue
I have a mapView class and a StoreFinder class. I want to be able to press a button that is in my AlertDialog, which holds geo-point values longitude and latitude. I want it to display the position of the longitude and latitude values in my MapView.
Simple:
Press button with longitude and latitude IN ALERTDIALOG -> MapView display position.
How would I go about doing this?
Thank you for your ample time.
CODE:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.storefinder_bars);
sirius();
}
public void sirius() {
ImageButton hoursButton = (ImageButton) findViewById(R.id.hours);
ImageButton addressButton = (ImageButton) findViewById(R.id.address);
//ImageButton phoneButton = (ImageButton) findViewById(R.id.phone);
final AlertDialog.Builder siriushours = new AlertDialog.Builder(this);
hoursButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
siriushours.setTitle("Opening Hours");
siriushours.setMessage(
"\n---Monday---\n" + "CLOSED"
+ "\n\n---Tuesday---\n" + "CLOSED"
+ "\n\n---Wednesday---\n" + "22:00 - 3:00"
+ "\n\n---Thursday---\n" + "CLOSED"
+ "\n\n---Friday---\n" + "22:00 - 3:00"
+ "\n\n---Saturday---\n" + "22:00 - 3:00"
+ "\n\n---Sunday---\n" + "CLOSED");
siriushours.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
siriushours.show();
}
});
//ADDRESS
final AlertDialog.Builder siriusadd = new AlertDialog.Builder(this);
addressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
siriusadd.setTitle("Address");
siriusadd.setMessage(
"33 Belvoir Street, Leicester , LE1 6SL");
siriusadd.setPositiveButton("Show On Map",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
}
});
siriusadd.setNegativeButton("Route",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr="+52.63274+","+-1.13145));
startActivity(intent);
}
});
siriusadd.show();
}
});
}
I want to make the POSITIVE BUTTON LOCATED HERE: "siriusadd.setPositiveButton("Show On Map", " to allow me to jump from the AlertDialog to my MapView geo-cordinate. If not, I have balloon itemized layout, I have markers in place. I would prefer if they would jump to that instead. However, geo-points would do.
Cheers for all the assistance.
Solution
Use MapController to animate to desired geopoint.
Instantiate MapController for your MapView:
private MapController mc;
mc = mapView.getController();
After initialization of dialog set onClickListener for button (here is example for positive button:
dialog.setPositiveButton(mContext.getString(R.string.photo), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
mc.animateTo(geoPoint);
}
});
Answered By - vtuhtan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.