Java 类com.google.android.gms.maps.GoogleMap.OnMapClickListener 实例源码

项目:Team9Project    文件:GeolocationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!isNetworkAvailable(this)) {
        startNetworkUnavailableDialog();
    }

    setContentView(R.layout.activity_geolocation);
    map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();

    Intent intent = getIntent();
    Geolocation location = (Geolocation) intent.getSerializableExtra(EXTRA_LOCATION);
    LatLng mapPosition = new LatLng(location.getLatitude(), location.getLongitude());
    marker = map.addMarker(new MarkerOptions().position(mapPosition));
    map.animateCamera(CameraUpdateFactory.newLatLng(mapPosition));

    map.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(LatLng point) {
            marker.setPosition(point);
            map.animateCamera(CameraUpdateFactory.newLatLng(point));
        }
    });
}
项目:oma-riista-android    文件:EditActivity.java   
@Override
public void onMapReady(GoogleMap map) {
    mLocationClient = getLocationClient();
    mLocationClient.addListener(this);

    updateMapPosition();

    if (mNew) {
        mMapView.setShowInfoWindow(true);
        mMapView.setShowAccuracy(true);
    }

    map.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(LatLng loaction) {
            viewMap();
        }
    });

    map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            viewMap();
            return true;
        }
    });
}
项目:TravelTracker    文件:SelectLocationFragment.java   
@Override
public void onResume() {
    super.onResume();

    // Set up map if we haven't done so yet
    if (map == null) {
        // Remove the toolbar
        map = mapFragment.getMap();
        UiSettings settings = map.getUiSettings();
        settings.setMapToolbarEnabled(false);

        if (editable) {
            map.setOnMapClickListener(new OnMapClickListener() {
                @Override
                public void onMapClick(LatLng arg0) {
                    launchSelectLocationActivity();
                }
            });
        }
    }

    updateMap();
}
项目:PalHunterClient    文件:GoogleMapFragment.java   
private void getViews(View v) {
  // (MapFragment) getChildFragmentManager().findFragmentById(R.id.map);
  mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager()
      .findFragmentById(R.id.map)).getMap();
  mMap.getUiSettings().setMyLocationButtonEnabled(true);
  mMap.setOnMapClickListener(new OnMapClickListener() {

    @Override
    public void onMapClick(LatLng point) {
      // TODO Auto-generated method stub
      mMap.addMarker(new MarkerOptions().position(point).title("Point")
          .snippet("Population: 4,137,400")
          .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
          .draggable(true));
      rectOptions.add(point);
      if (polyline != null) {
        polyline.remove();
      }
      polyline = mMap.addPolyline(rectOptions);
    }
  });
}
项目:egov-mobile    文件:MapActivity.java   
/**
 * Initialize the map view and set map click listener to map view. Tapping on any location will
 * show the marker on the location.
 */
private void _initilizeMap() {
    googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
            .getMap();

    if (googleMap == null) {
        _showMsg("Sorry! unable to create maps");
        return;
    }

    if (GeoLocation.getGpsStatus()) {
        if (defaultLat != 0 && defaultLng != 0) {
            _setLocation(defaultLat, defaultLng, false);
        } else {
            _setLocation(GeoLocation.getLatitude(), GeoLocation.getLongitude(), false);
        }
    } else {
        _showSettingsAlert();
    }

    googleMap.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng latLng) {
            latitude = latLng.latitude;
            longitude = latLng.longitude;
            MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.title("latitude" + latLng.latitude + ":" + latLng.longitude);
            markerOptions.position(latLng);
            googleMap.clear();
            googleMap.addMarker(markerOptions);
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
        }
    });
}
项目:tvm    文件:MainActivity.java   
@TargetApi(Build.VERSION_CODES.M)
private void initializeTracker() {
    app.textViewMessage1.setText(getString(R.string.tracker));
    app.layoutTopMessages.setBackgroundColor(getColor(R.color.teal600));
    googleMap.setOnMapClickListener(
            new OnMapClickListener() {
                @Override
                public void onMapClick(LatLng point) {
                    return; // do noth!
                }
            });
}
项目:tvm    文件:MainActivity.java   
@TargetApi(Build.VERSION_CODES.M)
private void initializeLogger() {
    app.textViewMessage1.setText(getString(R.string.logger));
    app.layoutTopMessages.setBackgroundColor(getColor(R.color.teal600));
    loggerSavedSpots = new ArrayList<Marker>();
    app.currentCoordinates = new LatLng(0, 0);
    googleMap.setOnMapClickListener(
            new OnMapClickListener() {

                @Override
                public void onMapClick(LatLng point) {

                    // Update coordinates
                    app.currentCoordinates = point;
                    updateDeveloperInfoLabels();

                    // Draw marker on this point

                    // If previous point exists, remove it
                    if (loggerTempMarker != null) {
                        loggerTempMarker.setPosition(point);
                        return;
                    }

                    // Add marker
                    loggerTempMarker =
                            googleMap.addMarker(
                                    new MarkerOptions()
                                            .position(point)
                                            .anchor(0.5f, 0.5f)
                                            .icon(
                                                    BitmapDescriptorFactory.fromResource(
                                                            R.drawable
                                                                    .vm_blue_dot_obscured_on)));
                }
            });
}
项目:University-GoDev    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // setting location manager to perform location related operations
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Requesting location manager for location updates
    locationManager.requestLocationUpdates(
            LocationManager.NETWORK_PROVIDER, 1, 1, this);

    // To get map from MapFragment from layout
    googleMap = ((MapFragment) getFragmentManager().findFragmentById(
            R.id.map)).getMap();

    // To change the map type to Satellite
     //googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

    // To show our current location in the map with dot
     googleMap.setMyLocationEnabled(true);

    // To listen action whenever we click on the map
    googleMap.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng latLng) {
            /*
             * LatLng:Class will give us selected position latigude and
             * longitude values
             */
            Toast.makeText(getApplicationContext(), latLng.toString(),
                    Toast.LENGTH_LONG).show();
        }
    });

}
项目:PalHunterClient    文件:HomeFragment.java   
private void initMap() {
  mMap = mMapView.getMap();
  mMap.getUiSettings().setMyLocationButtonEnabled(true);
  mMap.setMyLocationEnabled(true);
  mMap.setOnMapClickListener(new OnMapClickListener() {
    @Override
    public void onMapClick(LatLng point) {
      // TODO Auto-generated method stub
      mMap.addMarker(new MarkerOptions().position(point).title("Point")
          .snippet(point.toString())
          .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
          .draggable(true));
      rectOptions.add(point);
      if (polyline != null) {
        polyline.remove();
      }
      polyline = mMap.addPolyline(rectOptions);
    }
  });
  if (cameraPosition == null) {
    mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
      @Override
      public void onMyLocationChange(Location location) {

        CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(
            location.getLatitude(), location.getLongitude()));
        CameraUpdate zoom = CameraUpdateFactory.zoomTo(18);
        mMap.moveCamera(center);
        mMap.animateCamera(zoom);
        mMap.setOnMyLocationChangeListener(null);
      }
    });
  }
}
项目:map-controller    文件:MapController.java   
/**
 * when map is clicked
 *
 * @param callback
 */
public void whenMapClick(final ClickCallback callback) {
    map.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            callback.clicked(map, latLng);
        }
    });
}
项目:referendum_1o_android    文件:GoogleMapWrapper.java   
@Override
public final void setOnMapClickListener(OnMapClickListener listener) {
    map.setOnMapClickListener(listener);
}
项目:simple_weather    文件:MapActivity.java   
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMyLocationEnabled(true);
    mMap.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng latlng) {
            Intent intent = new Intent(MapActivity.this,
                    ForecastActivity.class);
            Bundle extras = new Bundle();
            extras.putParcelable(Constants.PARAM_LATLNG, latlng);
            intent.putExtras(extras);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                    | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    });
    if (getIntent().getBooleanExtra(Constants.PARAM_NO_LOCATION, false)) {
        Toast.makeText(this, R.string.no_location, Toast.LENGTH_SHORT)
                .show();
    }


    LatLng myPosition;


    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    googleMap.setMyLocationEnabled(true);
    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String provider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(provider);


    if (location != null) {
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        LatLng latLng = new LatLng(latitude, longitude);
        myPosition = new LatLng(latitude, longitude);


        LatLng coordinate = new LatLng(latitude, longitude);
        CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 19);
        mMap.animateCamera(yourLocation);
    }
}
项目:routelandia-android    文件:MapsActivity.java   
/**
 * Perform initialization of all fragments and loaders.
 *
 * @param savedInstanceState Bundle from Google SDK
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    setUpMapIfNeeded();

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available

        int requestCode = 10;
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
        dialog.show();

    } else { // Google Play Services are available
        // Getting reference to SupportMapFragment of the activity_maps
        SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

        // Getting Map for the SupportMapFragment
        mMap = fm.getMap();

        if(savedInstanceState != null){
            getItemsFromSaveBundle(savedInstanceState);

            // Redraw the map
            for (HashMap.Entry<Integer, List<Station>> entry : listOfStationsBaseOnHighwayid.entrySet()) {
                int highwayid = (int)entry.getKey();
                List<Station> tStationList = entry.getValue();
                int colorHighlightTheFreeWay = generatePairhighWayColor(highwayid);
                drawHighway(tStationList, colorHighlightTheFreeWay);
            }
        }
        else {
            activeAsyncs = 0;    // Make sure that we don't get stuck somehow
            initLoadingDialog();
            fetchHighwayData();
        }
    }


    // overwrite onMapClickListener to let users drag markerOptions in the map
    mMap.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(LatLng point) {
            drawMarker(point);
        }
    });

    goToDatePickUp();
}
项目:HereAStory-Android    文件:GoogleMapWrapper.java   
@Override
public final void setOnMapClickListener(OnMapClickListener listener) {
    map.setOnMapClickListener(listener);
}
项目:mtransit-for-android    文件:GoogleMapWrapper.java   
@Override
public final void setOnMapClickListener(OnMapClickListener listener) {
    map.setOnMapClickListener(listener);
}
项目:CS492-FA13    文件:MyGoogleMap.java   
@Override
  protected void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_google_map);

      // initialize icon drawables
      locIcon = R.drawable.bluedot;
      schoolIcon = R.drawable.university;
      workIcon = R.drawable.workoffice;
      beerIcon = R.drawable.beergarden;

      // initialize the map
      if(googleMap == null)
      { 
        // get the map fragment and the map object
        mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
        googleMap = mapFragment.getMap();

        // make sure the map exists before using
        if(googleMap != null)
    {
            // setup the map objects
              setupObjects();

              // set the location
            googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(camOriginal));

              // click listener
              googleMap.setOnMapClickListener(new OnMapClickListener()
              {
            @Override
            public void onMapClick(LatLng loc) 
            {
                updateMapFromClick(loc);
            }
              });

    }
}
  }
项目:referendum_1o_android    文件:IGoogleMap.java   
void setOnMapClickListener(OnMapClickListener listener);
项目:HereAStory-Android    文件:IGoogleMap.java   
void setOnMapClickListener(OnMapClickListener listener);
项目:mtransit-for-android    文件:IGoogleMap.java   
void setOnMapClickListener(OnMapClickListener listener);