How can I drag and drop a marker in a limited area?

How can I drag and drop a marker in a limited area? For instance, a circle has 20 meters radius. User can only drag and drop inside the circle. Here is the code I’ve tried. map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { mymarker.setPosition(latLng); mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); } }); map.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker … Continue reading “How can I drag and drop a marker in a limited area?”

Android- Wait to change latitude and longitude

Situation: I have a OpenActivity in which I wanna have current position, to do this I ask all permissions required, after, I want to open new activity and provide this data it. Problem: at the first launching I provide latitude and longitude = 0.00. Question: How I can resolve this problem? I want call new … Continue reading “Android- Wait to change latitude and longitude”

Cannot access Google API Client?

I’ve implemented GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener in my project (as well as it’s three callback methods onConnected, onConnectionSuspended, & onConnectionFailed), but I am unable to reference the Google Location API Client! (c is just an object that holds context) I’ve tried changing the parameters into this, volumeContentObserver.this, and even holding context in a variable beforehand and referencing … Continue reading “Cannot access Google API Client?”

How do I get place id using latitude and longitude?

I want to get place id using lat and lng. There is some code: mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { String title = marker.getTitle(); LatLng position = marker.getPosition(); marker.showInfoWindow(); double lat; double lng; lat = marker.getPosition().latitude; lng = marker.getPosition().longitude; return true; } }); When I click on marker I want to get … Continue reading “How do I get place id using latitude and longitude?”

Markers on Google Maps from JSON

Hello I have an android app that has a main menu with two buttons. First one gets you on a Google Maps screen and the other one on a screen that shows a listview with information(name, description, coordinates etc) from saved places on my MySQL database. This example shows exactly how I populate the lisview … Continue reading “Markers on Google Maps from JSON”

Android locationManager return NULL value

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); mprovider = locationManager.getBestProvider(criteria, false); if (mprovider != null && !mprovider.equals(“”)) { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } Location location = locationManager.getLastKnownLocation(mprovider); locationManager.requestLocationUpdates(mprovider, 1000, 15, SupplierList.this); if (location != null) onLocationChanged(location); else Toast.makeText(getBaseContext(), “No Location Provider Found Check Your Code”, … Continue reading “Android locationManager return NULL value”

How to call a method of the MapActivity from another activity in Android?

I am working on an Android application that based on Google Maps API. I have a refresh() method to refresh my MapActivity. I want to call the refresh() method to refresh the map after I managed my POIs from another activity. MapActivity.refresh(); This is my refresh() method: public void refresh() { Intent intent = getIntent(); … Continue reading “How to call a method of the MapActivity from another activity in Android?”

search location name in google map

I tried to search location name in google map in onsearch method address.getLatitude() and address.getLongitude are not work.its show red text.anyone please solve my error. below my code public void onSearch(View view) { EditText location_tf = (EditText)findViewById(; String location = location_tf.getText().toString(); List<Address> addressList = null; if(location != null || !location.equals(“”)) { Geocoder geocoder = … Continue reading “search location name in google map”

Send GPS position to the Web Service

I am trying to send coordinates of my position to the web service, I have a class called “LocationService” that should do this, but at the moment of executing the application nothing happens … LocationService public class LocationService extends Service implements LocationListener{ public String LOG = “Log”; UserSessionManager session; private Context mContext = null; boolean … Continue reading “Send GPS position to the Web Service”

Google maps in my custom activity

I’m trying to integrate Google maps to show a particular location in my activity, ResortDetails to display the latitude and longitude of the values I receive from my DB, but I am unable to do so. Here is my java code: public class ResortDetails extends AppCompatActivity implements View.OnClickListener, OnMapReadyCallback{ private GoogleMap mMap; protected void onCreate(Bundle … Continue reading “Google maps in my custom activity”