My aim is to draw markers based on GPS coordinates received from the WAMP server. I am not being able to draw the markers, what should I improve in my code in order to do so?
The following is the code responsible of getting data from a database running on WAMP server and drawing the markers on the map:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private RequestQueue requestQueue;
private double lat;
private double lon;
private int flag;
private String showUrl = "http://<<LOCAL-IP-ADDRESS>/directory/showSensor.php";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready
// to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
requestQueue = Volley.newRequestQueue(getApplicationContext());
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, showUrl,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray sensorLocations = response.getJSONArray("Sensor Locations");
for (int i = 0; i < sensorLocations.length(); i++) {
JSONObject sensorLocation = sensorLocations.getJSONObject(i);
String latitude = sensorLocation.getString("lat");
String longitude = sensorLocation.getString("long");
String flg = sensorLocation.getString("flag");
if (flag == 1) {
lat = Double.parseDouble(latitude);
lon = Double.parseDouble(longitude);
flag = 0;
}
}
;
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(jsonObjectRequest);
}
/**
* 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;
// Add a marker in Sydney and move the camera
LatLng sensor = new LatLng(lat, lon);
mMap.addMarker(new MarkerOptions().position(sensor).title(lat + "," + lon));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sensor));
}
}
It seems that the onMapReady method gets called before you receive a response from your server. Move the code to request data from your server to the onMapReady method:
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
requestQueue = Volley.newRequestQueue(getApplicationContext());
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST,
showUrl, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray sensorLocations = response.getJSONArray("Sensor Locations");
for (int i = 0; i < sensorLocations.length(); i++) {
JSONObject sensorLocation = sensorLocations.getJSONObject(i);
String latitude = sensorLocation.getString("lat");
String longitude= sensorLocation.getString("long");
String flg = sensorLocation.getString("flag");
if(flag ==1 ) {
lat = Double.parseDouble(latitude);
lon = Double.parseDouble(longitude);
flag=0;
LatLng sensor = new LatLng(lat, lon);
mMap.addMarker(new MarkerOptions().position(sensor).title(lat+ " " + lon));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sensor));
}
}
;
}catch(JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(jsonObjectRequest);
}
Related
I am currently developing an application in which i want to know if a route contains a certain set of lat long coordinates. Here is my code:
public class PathActivity extends FragmentActivity implements OnMapReadyCallback, RoutingListener {
private GoogleMap mMap;
FetchLocation fetchLocation;
LatLng start;
LatLng end;
ProgressDialog pd;
List<Polyline> polylines;
private static final int[] COLORS = new int[]{R.color.gradient_dark_pink};
FirebaseFirestore firestore;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_path);
//Receiving Object From Intent
Intent rcv = getIntent();
fetchLocation = (FetchLocation) rcv.getSerializableExtra("keyFetchLocationObject2");
pd = new ProgressDialog(this);
pd.setMessage("Please Wait...");
firestore = FirebaseFirestore.getInstance();
fetchAllTrafficLights();
polylines = new ArrayList<>();
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
pd.show();
//Making a Path
start = new LatLng(fetchLocation.latitude, fetchLocation.longitude);
end = new LatLng(fetchLocation.destinationLatitude, fetchLocation.destinationLongitude);
Routing routing = new Routing.Builder()
.travelMode(Routing.TravelMode.DRIVING)
.withListener(this)
.alternativeRoutes(false)
.waypoints(start, end)
.build();
routing.execute();
}
#Override
public void onRoutingFailure(RouteException e)
{
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
pd.dismiss();
}
#Override
public void onRoutingStart() {
}
#Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex)
{
pd.dismiss();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 16));
if(polylines.size()>0) {
for (Polyline poly : polylines) {
poly.remove();
}
}
polylines = new ArrayList<>();
//add route(s) to the map.
for (int i = 0; i <route.size(); i++)
{
//In case of more than 5 alternative routes
int colorIndex = i % COLORS.length;
PolylineOptions polyOptions = new PolylineOptions();
polyOptions.color(getResources().getColor(COLORS[colorIndex]));
polyOptions.width(10 + i * 3);
polyOptions.addAll(route.get(i).getPoints());
Polyline polyline = mMap.addPolyline(polyOptions);
polylines.add(polyline);
Toast.makeText(getApplicationContext(),"Route "+ (i+1) +": distance - "+ route.get(i).getDistanceValue()+": duration - "+ route.get(i).getDurationValue(),Toast.LENGTH_SHORT).show();
// Start marker
MarkerOptions options = new MarkerOptions();
options.position(start);
options.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_start_blue));
mMap.addMarker(options);
// End marker
options = new MarkerOptions();
options.position(end);
options.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_end_green));
mMap.addMarker(options);
}
}
#Override
public void onRoutingCancelled() {
}
public void fetchAllTrafficLights()
{
pd.show();
firestore.collection("Controller").get().addOnCompleteListener(this, new OnCompleteListener<QuerySnapshot>() {
#Override
public void onComplete(Task<QuerySnapshot> task)
{
if(task.isSuccessful())
{
for(QueryDocumentSnapshot documentSnapshot : task.getResult())
{
Log.i("Hello", documentSnapshot.get("controllerLatitude").toString() + " " + documentSnapshot.get("controllerLongitude").toString());
pd.dismiss();
}
}
}
})
.addOnFailureListener(this, new OnFailureListener()
{
#Override
public void onFailure(Exception e)
{
Toast.makeText(PathActivity.this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
pd.dismiss();
}
});
}
}
I am using github library: https://github.com/jd-alexander/Google-Directions-Android to draw the route between two points.
The coordinated are already saved in the firestore database and are successfully fetched as shown in Log. Now I want to check if the lat long points fetched from database are in the path or not. Eg. If we move from point A to D, I want to check points B,C are present on the route or not. I also want to know does the google places api always give same route coordinates between two locations. Here is my object:
public class FetchLocation implements Serializable
{
public double latitude;
public double longitude;
public double destinationLatitude;
public double destinationLongitude;
public FetchLocation()
{
}
public FetchLocation(double latitude, double longitude, double destinationLatitude, double destinationLongitude) {
this.latitude = latitude;
this.longitude = longitude;
this.destinationLatitude = destinationLatitude;
this.destinationLongitude = destinationLongitude;
}
#Override
public String toString() {
return "FetchLocation{" +
"latitude=" + latitude +
", longitude=" + longitude +
", destinationLatitude=" + destinationLatitude +
", destinationLongitude=" + destinationLongitude +
'}';
}
}
The users source lat long are fetched in the previous activity using google place autocomplete- https://developers.google.com/places/android-sdk/autocomplete and are set in the object which is passed to this activity.
Anyone please help!!
Take a look at PolyUtil.isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance) method of Google Maps Android API Utility Library. You need to get polyline path from A to D and check each point from list (B and C) with isLocationOnPath() if it laying on A-D path. Something like that:
for (LatLng point : pointsBandCList) {
if (PolyUtil.isLocationOnPath(point, polylineFromAtoD.getPoints(), true, 100)) {
// "point" laying on A to D path
...
}
}
where 100 - is tolerance (in meters). You can adjust it for your task.
I am currently working with the google map. I already show the markers and the title and snippet of the marker.
Now my problem is when I click the info window it will be redirected to a new activity and get the data of the marker that was clicked. Here is my code:
public class FindApartment extends Fragment implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener,GoogleMap.OnInfoWindowClickListener {
public static final String ID = "id";
public static final String VERIFICATION = "verification";
private static final String TAG_APARTMENTNAME = "apartmentName";
private static final String TAG_CATEGORY = "Category";
private static final String TAG_PRICE = "price_month";
public static final String LAT = "latt";
public static final String LNG = "longt";
MarkerOptions markerOptions = new MarkerOptions();
CameraPosition cameraPosition;
LatLng center, latLng;
String verification, apartmentname, category, price, id;
GoogleMap mGoogleMap;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
MapView mapView;
String tag_json_obj = "json_obj_req";
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_find_apartment, container, false);
mapView = (MapView) rootView.findViewById(R.id.map1);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
mapView.onResume();
return rootView;
}
#Override
public void onPause() {
super.onPause();
//stop location updates when Activity is no longer active
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
#Override
public void onLocationChanged(Location location) {
mLastLocation = location;
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions myMarker = new MarkerOptions();
myMarker.position(latLng);
myMarker.title("me");
myMarker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
mCurrLocationMarker = mGoogleMap.addMarker(myMarker);
//move map camera
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,17));
getMarkers();
}
#Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap=googleMap;
mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mGoogleMap.setOnInfoWindowClickListener(this);
if(mGoogleMap!= null){
mGoogleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
#Override
public View getInfoWindow(Marker marker) {
return null;
}
#Override
public View getInfoContents(Marker marker) {
View view = getLayoutInflater().inflate(R.layout.info_window, null);
TextView textName = (TextView) view.findViewById(R.id.textName);
TextView textViewPrice = (TextView) view.findViewById(R.id.textViewPrice);
TextView detail = (TextView)view.findViewById(R.id.detail);
LatLng ll = marker.getPosition();
textName.setText(marker.getSnippet());
textViewPrice.setText(marker.getTitle());
detail.setText("click to see full detail");
return view;
}
});
}
I'm using Android Volley and the array is on the Stringrequest. How can I get the data of the marker that was clicked on info window?
private void addMarker(LatLng latLng, String category, final String price, final String id) {
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title(price);
markerOptions.snippet(category);
markerOption(verification, markerOptions);
mGoogleMap.addMarker(markerOptions);
}
public void onInfoWindowClick(Marker marker) {
id = marker.getId();
String snippet = marker.getSnippet();
Intent intent = new Intent(getActivity(), InfoWindowActivity.class);
startActivity(intent);
}
private void markerOption(String verification, MarkerOptions markerOptions) {
if(verification.contains("pending")) {
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
}
else {
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
}
}
private void getMarkers() {
String url = Server.URL2 + "markers.php";
final HashMap<String, String> apartmentID = new HashMap<String, String>();
StringRequest strReq = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.e("Response: ", response.toString());
try {
JSONObject jObj = new JSONObject(response);
String getObject = jObj.getString("apartments");
JSONArray jsonArray = new JSONArray(getObject);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
verification = jsonObject.getString(VERIFICATION);
apartmentname = jsonObject.getString(TAG_APARTMENTNAME);
category = jsonObject.getString(TAG_CATEGORY);
price = jsonObject.getString(TAG_PRICE);
id = jsonObject.getString("userID");
apartmentID.put(ID, id);
latLng = new LatLng(Double.parseDouble(jsonObject.getString(LAT)), Double.parseDouble(jsonObject.getString(LNG)));
// Adds a data marker to show to google map
addMarker(latLng, category, price, id);
}
} catch (JSONException e) {
// JSON error
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show();
}
});
AppController.getInstance().addToRequestQueue(strReq, tag_json_obj);
}
Intent intent = new Intent(getActivity(), InfoWindowActivity.class);
intent.putExtra("snippet", snippet);
intent.putExtra("id", id)
... //put all your info here
startActivity(intent);
Access that data on next activity for example in onCreate or wherever you need it.
String snippet = getIntent().getStringExtra("snippet");
int id = getIntent().getIntExtra("id");
...//get all your info here
Is it what you were looking for? Question is not completely clear..
I have this code where i have to call data from database yung asynctask the coordinates for my googlemap. but the onMapReady is executing before my Asynctask so the location is always null. I call the asynctask on my oncreate here is my code.
AsyncTask on onCreate
HashMap<String, String> postData = new HashMap<>();
postData.put("rqstID", rqstID);
AsyncClass taskDetails = new AsyncClass(AcceptActivity.this, postData, "Getting details", new AsyncResponse() {
#Override
public void processFinish(String s) {
Log.d("AcceptActivity", s);
JSONObject parentObject = null;
try {
parentObject = new JSONObject(s);
JSONArray parentArray = parentObject.getJSONArray("result");
JSONObject finalObject = parentArray.getJSONObject(0);
lat1 = finalObject.getString("rqstLat");
lng1 = finalObject.getString("rqstLng");
} catch (JSONException e) {
e.printStackTrace();
}
}
});
taskDetails.execute("http://10.0.2.2/wingman/requestDetails.php");
onMapReady
#Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
LatLng location = new LatLng(Double.valueOf(lat1), Double.valueOf(lng1));
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(location, 15);
mGoogleMap.moveCamera(update);
MarkerOptions options = new MarkerOptions()
.position(location)
.snippet("I'm around here!!!");
CircleOptions circle = new CircleOptions()
.center(location)
.radius(2000)
.fillColor(0x55add8e6)
.strokeColor(Color.BLUE)
.strokeWidth(2);
mGoogleMap.addCircle(circle);
mGoogleMap.addMarker(options);
}
There is no way to guarantee that your async task could complete before the Google map's onMapReady() were called. Instead, I propose that you make the REST call for map information from the onMapReady() method itself. This way, you can be sure that when the callback is fired, there is an actual live Google map handle to which you could assign a marker etc.
Here is a skeleton of what the code might look like:
#Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
new YourAsyncTask(this).execute();
}
Then in your async task you can parse the data and assign the marker to your Google Map.
I think you have to make a function for what ever task you want to perform on map basis on user experience and pass parameter related which value you need to perform your task on map like latitude longitude.
private void yourFunctionName(double lat1, double lng1){
LatLng location = new LatLng(Double.valueOf(lat1), Double.valueOf(lng1));
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(location, 15);
mGoogleMap.moveCamera(update);
MarkerOptions options = new MarkerOptions()
.position(location)
.snippet("I'm around here!!!");
CircleOptions circle = new CircleOptions()
.center(location)
.radius(2000)
.fillColor(0x55add8e6)
.strokeColor(Color.BLUE)
.strokeWidth(2);
mGoogleMap.addCircle(circle);
mGoogleMap.addMarker(options);
}
you not need to perform any task in onMapReady() function
#Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
}
store only google map object
mGoogleMap = googleMap;
now perform network operation and call which function you want to perform
HashMap<String, String> postData = new HashMap<>();
postData.put("rqstID", rqstID);
AsyncClass taskDetails = new AsyncClass(AcceptActivity.this, postData,
"Getting details", new AsyncResponse() {
#Override
public void processFinish(String s) {
Log.d("AcceptActivity", s);
JSONObject parentObject = null;
try {
parentObject = new JSONObject(s);
JSONArray parentArray = parentObject.getJSONArray("result");
JSONObject finalObject = parentArray.getJSONObject(0);
lat1 = finalObject.getString("rqstLat");
lng1 = finalObject.getString("rqstLng");
yourFunctionName(Lat1, lng1) // CALL THIS AFTER GETED RESULT
} catch (JSONException e) {
e.printStackTrace();
}
}
});
taskDetails.execute("http://10.0.2.2/wingman/requestDetails.php");
Adding Async in onMapReady() won't help, instead replace somefragment.getMapAsync(this) with your Async task call and add somefragment.getMapAsync(this) in the end of onPostExecute.
I am trying to plot longitude latitude values from MySql on google map with marker. Code for fetching longitude latitude value is correct as code displays those values while using Toast Message. The problem is that everything goes fine except I can't see any markers on google map. Here is my source code.
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private String JSON_STRING;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
getJSON();
/* LatLng sydney = new LatLng(33, 88);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
*/
}
private void showLongLat(){
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(JSON_STRING);
JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY);
for(int i = 0; i<result.length(); i++){
JSONObject jo = result.getJSONObject(i);
String id = jo.getString(Config.TAG_ID);
String longitude = jo.getString(Config.TAG_LONG);
String latitude = jo.getString(Config.TAG_LAT);
Toast.makeText(getApplicationContext(),latitude+longitude,Toast.LENGTH_LONG).show();
LatLng marker = new LatLng(Double.parseDouble(longitude),Double.parseDouble(latitude));
//LatLng sydney = new LatLng(42+i,87-i);
mMap.addMarker(new MarkerOptions().position(marker).title("Marker Somewhere"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(marker));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
private void getJSON(){
class GetJSON extends AsyncTask<Void,Void,String>{
ProgressDialog loading;
#Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(MapsActivity.this,"Fetching Data","Wait...",false,false);
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
loading.dismiss();
JSON_STRING = s;
showLongLat();
}
#Override
protected String doInBackground(Void... params) {
RequestHandler rh = new RequestHandler();
String s = rh.sendGetRequest(Config.URL_GET_ALL);
return s;
}
}
GetJSON gj = new GetJSON();
gj.execute();
}
}
You are changing the values of latitude and longitude. This line:
LatLng marker = new LatLng(Double.parseDouble(longitude),Double.parseDouble(latitude));
Must be:
LatLng marker = new LatLng(Double.parseDouble(latitude),Double.parseDouble(longitude));
i created an application that retrieved data from mysql databse. the problem is that the map does not show any marker .
i am using volley library
public class MainActivity extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpMapIfNeeded();
String uri = "localhost/get_all_products.php";
RequestQueue mRequestQueue = Volley.newRequestQueue(getApplicationContext());
JsonArrayRequest request = new JsonArrayRequest(
uri,
new Response.Listener<JSONArray>(){
LatLng location;
#Override
public void onResponse(JSONArray response) {
int count = response.length();
for(int i = 0; i < count; i++){
try {
JSONObject jo = response.getJSONObject(i);
Double lat = Double.parseDouble(jo.getString("lat"));
Double lng = Double.parseDouble(jo.getString("lng"));
location = new LatLng(lat,lng);
MarkerOptions options = new MarkerOptions();
options.position(location);
options.title(jo.getString("product"));
options.snippet(jo.getString("product"));
mMap.addMarker(options);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
CameraUpdate cu = CameraUpdateFactory.newLatLng(location);
mMap.moveCamera(cu);
Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "onErrorResponse", Toast.LENGTH_LONG).show();
}
}
);
Object TAG_REQUEST_QUEUE = new Object();
request.setTag(TAG_REQUEST_QUEUE);
mRequestQueue.add(request);
mRequestQueue.start();
}
#Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
if (mMap != null) {
}
}
}
}
the map is rteurn without any markers and the application does not crash.
the php files are correct so there is no need to put the code here
thank you :)
--------EDIT
the volley error i get is
org.json.JSONException: value <html><body><script of type java.lang.String cannot be converted to JSONArray
the problem is not in the java or php files.
the host "byethost14.com" is not giving a valid json format for security purposes i guess.
i changed the url to 10.0.2.2 and uploaded my files in xamppserver and it's working
-------advice------
do not use byethost if you want to output json