Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. public void onMapReady(GoogleMap googleMap) {
  2. mMap = googleMap;
  3.  
  4. LatLng CCU = new LatLng(23.558581, 120.471984);
  5. mMap.addMarker(new MarkerOptions().position(CCU).title("施工").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
  6.  
  7. mMap.getUiSettings().setCompassEnabled(true);
  8. mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(CCU, 15));
  9.  
  10.  
  11. mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener()
  12. {
  13. @Override
  14. public void onMapClick(LatLng point)
  15. {
  16.  
  17. AlertDialog.Builder builder;
  18. AlertDialog alertDialog;
  19. Context mContext = Contact2Fragment.this.getContext();
  20. LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  21. View view = vi.inflate(R.layout.alertdialog, null);
  22. RadioGroup rg = (RadioGroup)view.findViewById(R.id.RadioGroup);
  23. lat = point.latitude;
  24. lon = point.longitude;
  25. final EditText editText = (EditText) view.findViewById(R.id.input);
  26.  
  27. builder = new AlertDialog.Builder(mContext);
  28. builder.setView(view);
  29.  
  30. builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
  31. public void onClick(DialogInterface dialog, int which) {
  32. dialog.dismiss();
  33. }
  34. });
  35.  
  36. builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  37. public void onClick(DialogInterface dialog, int which) {
  38.  
  39. Context mContext = Contact2Fragment.this.getContext();
  40. LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  41. View view = vi.inflate(R.layout.alertdialog, null);
  42. RadioGroup rg = (RadioGroup)view.findViewById(R.id.RadioGroup);
  43. String m_Text = editText.getText().toString();
  44.  
  45. final MarkerOptions marker = new MarkerOptions().position(new LatLng(lat,lon)).title( m_Text);
  46. switch (rg.getCheckedRadioButtonId()){
  47. case R.id.radioButton_Green:{
  48. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
  49. break;
  50. }
  51. case R.id.radioButton_Yellow: {
  52. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)) ;
  53. break;
  54. }
  55. case R.id.radioButton_Red: {
  56. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
  57. break;
  58. }
  59. }
  60. rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  61. @Override
  62. public void onCheckedChanged(RadioGroup group, int checkedId) {
  63. switch (checkedId){
  64. case R.id.radioButton_Green:
  65. group.check(R.id.radioButton_Green);
  66. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
  67. break;
  68. case R.id.radioButton_Yellow:
  69. group.check(R.id.radioButton_Yellow);
  70. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)) ;
  71. break;
  72. case R.id.radioButton_Red:
  73. group.check(R.id.radioButton_Red);
  74. marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)) ;
  75. break;
  76. }
  77. }
  78. });
  79. dialog.dismiss();
  80. mMap.addMarker(marker);
  81. }
  82. });
  83. alertDialog = builder.create();
  84. alertDialog.setTitle("Describe the situation");
  85. alertDialog.show();
  86. }
  87. });
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement