Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onMapReady(GoogleMap googleMap) {
- mMap = googleMap;
- LatLng CCU = new LatLng(23.558581, 120.471984);
- mMap.addMarker(new MarkerOptions().position(CCU).title("施工").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
- mMap.getUiSettings().setCompassEnabled(true);
- mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(CCU, 15));
- mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener()
- {
- @Override
- public void onMapClick(LatLng point)
- {
- AlertDialog.Builder builder;
- AlertDialog alertDialog;
- Context mContext = Contact2Fragment.this.getContext();
- LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View view = vi.inflate(R.layout.alertdialog, null);
- RadioGroup rg = (RadioGroup)view.findViewById(R.id.RadioGroup);
- lat = point.latitude;
- lon = point.longitude;
- final EditText editText = (EditText) view.findViewById(R.id.input);
- builder = new AlertDialog.Builder(mContext);
- builder.setView(view);
- builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- });
- builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Context mContext = Contact2Fragment.this.getContext();
- LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View view = vi.inflate(R.layout.alertdialog, null);
- RadioGroup rg = (RadioGroup)view.findViewById(R.id.RadioGroup);
- String m_Text = editText.getText().toString();
- final MarkerOptions marker = new MarkerOptions().position(new LatLng(lat,lon)).title( m_Text);
- switch (rg.getCheckedRadioButtonId()){
- case R.id.radioButton_Green:{
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
- break;
- }
- case R.id.radioButton_Yellow: {
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)) ;
- break;
- }
- case R.id.radioButton_Red: {
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
- break;
- }
- }
- rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- switch (checkedId){
- case R.id.radioButton_Green:
- group.check(R.id.radioButton_Green);
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
- break;
- case R.id.radioButton_Yellow:
- group.check(R.id.radioButton_Yellow);
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)) ;
- break;
- case R.id.radioButton_Red:
- group.check(R.id.radioButton_Red);
- marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)) ;
- break;
- }
- }
- });
- dialog.dismiss();
- mMap.addMarker(marker);
- }
- });
- alertDialog = builder.create();
- alertDialog.setTitle("Describe the situation");
- alertDialog.show();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement