No markers from json php mysql localdatabase on google maps
<p>I am a beginner in programming and I just want to create an app that display some markers on map using some coordinates from a localdatabase (MySQL), using PHP and JSON.The map is working, but there are no markers. Please help me because I really cannot figure it out.</p>

<p>This is the error i get:</p>

<blockquote>
  <p>Error processing JSON<br>
  &nbsp;&nbsp;org.json.JSONException: End of input at character 0 of<br>
  &nbsp;&nbsp;at org.json.JSONTokener.syntaxError(JSONTokener.java:450)<br>
  &nbsp;&nbsp;at org.json.JSONTokener.nextValue(JSONTokener.java:97)<br>
  &nbsp;&nbsp;at org.json.JSONArray.(JSONArray.java:92)<br>
  &nbsp;&nbsp;at org.json.JSONArray.(JSONArray.java:108)<br>
  &nbsp;&nbsp;at com.kid.compaq.licenta.MapsActivity$MarkerTask.onPostExecute(MapsActivity.java:108)<br>
  &nbsp;&nbsp;at com.kid.compaq.licenta.MapsActivity$MarkerTask.onPostExecute(MapsActivity.java:62)<br>
  &nbsp;&nbsp;at android.os.AsyncTask.finish(AsyncTask.java:636)<br>
  &nbsp;&nbsp;at android.os.AsyncTask.access$500(AsyncTask.java:177)<br>
  &nbsp;&nbsp;at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)<br>
  &nbsp;&nbsp;at android.os.Handler.dispatchMessage(Handler.java:111)<br>
  &nbsp;&nbsp;at android.os.Looper.loop(Looper.java:194)<br>
  &nbsp;&nbsp;at android.app.ActivityThread.main(ActivityThread.java:5637)<br>
  &nbsp;&nbsp;at java.lang.reflect.Method.invoke(Native Method)<br>
  &nbsp;&nbsp;at java.lang.reflect.Method.invoke(Method.java:372)<br>
  &nbsp;&nbsp;at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)<br>
  &nbsp;&nbsp;at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)  </p>
</blockquote>

<p>This is my MapActivity</p>

<pre><code>import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;

    @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);
        new MarkerTask().execute();
    }


    /**
     * 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.getUiSettings().isCompassEnabled();
        mMap.getUiSettings().setZoomControlsEnabled(true);
        mMap.getUiSettings().setScrollGesturesEnabled(true);
        mMap.getUiSettings().setMapToolbarEnabled(true);



    }
    class MarkerTask extends AsyncTask&lt;Void, Void, String&gt; {

        public static final String LOG_TAG = "ExampleApp";

        public static final String SERVICE_URL = "http://192.168.48.14/stations.php";

        // Invoked by execute() method of this object
        @Override
        protected String doInBackground(Void... args) {

            HttpURLConnection conn;
            InputStream in = null;
            String result = "";

            try {
                URL url = new URL(SERVICE_URL);
                conn = (HttpURLConnection) url.openConnection();
                conn.connect();
                in = conn.getInputStream();


            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                assert in != null;
                BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"));
                String line;
                while ((line = reader.readLine()) != null) {
                    result += line;
                }
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return result;

        }


        // Executed after the complete execution of doInBackground() method
        @Override
        protected void onPostExecute(String result) {

            try {
                JSONArray jsonArray = new JSONArray(result);
                for (int i = 0; i &lt; jsonArray.length(); i++) {
                    JSONObject jsonObj = jsonArray.getJSONObject(i);

                    LatLng latLng = new LatLng(jsonObj.getJSONArray("latlng").getDouble(0),
                            jsonObj.getJSONArray("latlng").getDouble(1));


                    // Create a marker for each station in the JSON data.
                    mMap.addMarker(new MarkerOptions()
                            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))
                            .title(jsonObj.getString("nume"))
                            .position(latLng));
                }
            } catch (JSONException e) {
                Log.e(LOG_TAG, "Error processing JSON", e);
            }

        }
    }
}
</code></pre>

<p>This is my php script</p>

<pre><code>&lt;?php

    $username = "root";
    $password = "";
    $hostname = "localhost"; 

    //connection to the database
    @$dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");

    $selected = mysql_select_db("incercare",$dbhandle)or die("Could not select licenta");


        $sql="SELECT id_st, nume, CONCAT_WS(\",\",lat, lng) AS latlng FROM statii";
        $result = mysql_query($sql);
        $response= array();
        while($row= mysql_fetch_assoc($result)){

            $response[]=array(
                                'nume'          =&gt; $row['nume'],
                                'latlng'        =&gt; explode(',', $row['latlng']),
                                'id_st'         =&gt; $row['id_st']
                                );
        }

    $bd_json = json_encode($response);
    echo json_encode($response);
    ?&gt;
</code></pre>

<p>and this is my json output</p>

<pre><code>[{"nume":"Merge in sfarsit","latlng":["45.659721","25.606859"],"id_st":"5"},{"nume":"Memo Cantina","latlng":["45.655075","25.581560"],"id_st":"6"}]
</code></pre>

<p>Any idea on what is wrong and what must be done in order to make it work?</p>