1

I'm trying to develop my own map. I have got ahead till somewhere. Now i'm trying to add place filter on my app. So i reached and found this link I implemented and it works. But the problem is it doesnt find all bus stations or all banks around me. I'm from Turkey and i thought maybe it could work well in USA but it connects to GPS so i couldn't try for different state (country). Does anyone know, how i can handle with this?

Ensar
  • 17
  • 4

2 Answers2

2

Just temporarily use hard-coded values for latitude and longitude in order to test your code with any location you want.

Replace your code with this in order to test your code with San Francisco as a location:

            @Override
            public void onClick(View v) {

                double testLat = 37.7942635; //added
                double testLon =  -122.3955861; //added

                int selectedPosition = mSprPlaceType.getSelectedItemPosition();
                String type = mPlaceType[selectedPosition];
                StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
                sb.append("location=" + testLat + "," + testLon ); //modified
                sb.append("&radius=5000");
                sb.append("&types="+type);
                sb.append("&sensor=true");
                sb.append("&key=YOUR_API_KEY");

                // Creating a new non-ui thread task to download json data
                PlacesTask placesTask = new PlacesTask();

                // Invokes the "doInBackground()" method of the class PlaceTask
                placesTask.execute(sb.toString());

            }
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
1

Try with an emulator. I emulated my position with Genymotion, but it was quite long to install and setup everything.

You might first try to emulate your position with the official emulator, as it seems to be possible now. Check this out.

Community
  • 1
  • 1
Gordak
  • 2,060
  • 22
  • 32
  • weird but i used emulator as you said, when i specified my location as in New York(or anywhere else), the function doesnt work. but when i specified as my real location, it works. – Ensar May 26 '15 at 20:09