MapPlaces
BackgroundTask.java
This is a backgroundTask AsyncTask file to get the nearby places details and update in List<FindPlaces>.
|
package com.places.map.mapplaces;
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Locale; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.ProgressDialog; import android.location.Address; import android.location.Location; import android.os.AsyncTask; import android.text.Layout; import android.util.AndroidException; import android.util.Log; import android.view.View; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.Toast; import javax.net.ssl.HttpsURLConnection; public class BackgroundTask extends AsyncTask<String, Void, String> { String Result; String npage; LinearLayout spinner=null; public BackgroundTask(LinearLayout spinner) { this.spinner =spinner; } StringBuilder sb = new StringBuilder(); @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected void onPostExecute(String result) { spinner.setVisibility(View.GONE); } @Override protected String doInBackground(String... arg0) { String link1 = (String) arg0[0]; Result = link( link1); return Result; } // This method is used to establish a connection to PHP file. // SQL query and link to PHP file is passed as parameter. public String link(String link1) { try { String data = URLEncoder.encode("query", "UTF-8") + "=" + URLEncoder.encode("", "UTF-8"); URL url = new URL(link1); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); // URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(""); wr.flush(); wr.close(); String line = null; BufferedReader reader = new BufferedReader(new InputStreamReader( conn.getInputStream())); while ((line = reader.readLine()) != null) { sb.append(line); } } catch (Exception e) { e.printStackTrace(); } return sb.toString(); } // get the data in array format for adapter. jsondata is passed with database fields. // This method is for offers details adapter and show data in ListView. public List<FindPlaces> getplaces(String jsondata, String[] data,String token) { List<FindPlaces> allplaces = new LinkedList<FindPlaces>(); try { JSONObject jobject = new JSONObject(jsondata); JSONArray jmain = jobject.optJSONArray("results"); token = jobject.optString("next_page_token"); Double lng,lat; for (int i = 0; i < jmain.length(); i++) { JSONObject jchild = jmain.getJSONObject(i); FindPlaces findPlace = new FindPlaces(); Log.v("location",jchild.toString()); findPlace.setId(i); findPlace.setName(jchild.optString(data[1])); findPlace.setVicinity(jchild.optString(data[2])); lat = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); lng = jchild .getJSONObject("geometry").getJSONObject("location").getDouble("lng"); findPlace.setLat(lat); findPlace.setLng(lng); findPlace.setTypes(jchild.optJSONObject(data[5])); allplaces.add(findPlace); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return allplaces; } /* public Location getlocation(String jsondata) { // List<Address> allplaces = new LinkedList<Address>(); Location loc= null; try { JSONObject jobject = new JSONObject(jsondata); JSONArray jmain = jobject.optJSONArray("results"); Double lng,lat; for (int i = 0; i < jmain.length(); i++) { JSONObject jchild = jmain.getJSONObject(i); // Address address = new Address(Locale.getDefault()); Log.v("location",jchild.toString()); lat = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); lng = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lng"); loc.setLongitude(lng); loc.setLatitude(lat); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return loc; } */ } |
FindLocation.java
This is a class file to store the location details as lat and lng.
|
package com.places.map.mapplaces; import org.json.JSONObject;import static android.R.attr.id; public class FindLocation { private Double lng; private Double lat; public Double getLng() { return lng; } public void setLng(Double lng) { this.lng = lng; } public Double getLat() { return lat; } public void setLat(Double lat) { this.lat = lat; } } |
FindPlaces.java
This is a class file with getter and setter for places names details. This class will be used to store details for nearby places in list.
|
package com.places.map.mapplaces; import android.location.Location; import org.json.JSONObject; public class FindPlaces { public int id; public String name; public String vicinity; public String getToken() { return token; } public void setToken(String token) { this.token = token; } public String token; public JSONObject getTypes() { return types; } public void setTypes(JSONObject types) { this.types = types; } public JSONObject getLoc() { return loc; } public void setLoc(JSONObject loc) { this.loc = loc; } public JSONObject types; private JSONObject loc; public Double getLat() { return lat; } public void setLat(Double lat) { this.lat = lat; } private Double lat; public Double getLng() { return lng; } public void setLng(Double lng) { this.lng = lng; } private Double lng; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getVicinity() { return vicinity; } public void setVicinity(String vicinity) { this.vicinity = vicinity; } } |
LocBackgroundTask.java
This is a Background Task file , AsyncTask to first define the location lat/lng for the place name entered to search and show map as required location. Later nearby places will be searched for this location.
|
package com.places.map.mapplaces; import android.app.ProgressDialog; import android.content.Context; import android.location.Location; import android.os.AsyncTask; import android.util.Log; import android.view.View; import android.widget.LinearLayout; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.LinkedList; import java.util.List; import java.util.Locale; import javax.net.ssl.HttpsURLConnection; public class LocBackgroundTask extends AsyncTask<String, Void, String> { String Result; LinearLayout spinner=null; Context context; private ProgressDialog pdia; StringBuilder sb = new StringBuilder(); public LocBackgroundTask(LinearLayout spinner) { this.spinner =spinner;this.context=context; } @Override protected void onPreExecute() { this.spinner.setVisibility(View.VISIBLE); } @Override protected String doInBackground(String... arg0) { String link1 = (String) arg0[0]; Result = link( link1); return Result; } @Override protected void onPostExecute(String result) { } // This method is used to establish a connection to PHP file. // SQL query and link to PHP file is passed as parameter. public String link(String url) { String result = ""; try { URL urls = new URL(url.replace(" ","%20")); HttpURLConnection conn = (HttpURLConnection) urls.openConnection(); conn.setReadTimeout(150000) ; //milliseconds conn.setConnectTimeout(15000) ; // milliseconds conn.setRequestMethod("POST") ; conn.connect(); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader( conn.getInputStream(), "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } result = sb.toString(); } else { return "error"; } } catch (Exception e) { // System.out.println("exception in jsonparser class ........"); e.printStackTrace(); return "error"; } return result; } // method ends /* // get the data in array format for adapter. jsondata is passed with database fields. // This method is for offers details adapter and show data in ListView. public List<FindPlaces> getplaces(String jsondata, String[] data) { List<FindPlaces> allplaces = new LinkedList<FindPlaces>(); try { JSONObject jobject = new JSONObject(jsondata); JSONArray jmain = jobject.optJSONArray("results"); Double lng,lat; for (int i = 0; i < jmain.length(); i++) { JSONObject jchild = jmain.getJSONObject(i); FindPlaces findPlace = new FindPlaces(); Log.v("location",jchild.toString()); findPlace.setId(i); findPlace.setName(jchild.optString(data[1])); findPlace.setVicinity(jchild.optString(data[2])); lat = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); lng = jchild .getJSONObject("geometry").getJSONObject("location").getDouble("lng"); findPlace.setLat(lat); findPlace.setLng(lng); findPlace.setTypes(jchild.optJSONObject(data[5])); allplaces.add(findPlace); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return allplaces; } */ public Location getlocation(String jsondata) { // List<Address> allplaces = new LinkedList<Address>(); Location loc= new Location("network"); try { JSONObject jobject = new JSONObject(jsondata); JSONArray jmain = jobject.optJSONArray("results"); Double lng,lat; for (int i = 0; i < jmain.length(); i++) { JSONObject jchild = jmain.getJSONObject(i); // Address address = new Address(Locale.getDefault()); Log.v("location",jchild.toString()); lat = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); lng = jchild.getJSONObject("geometry").getJSONObject("location").getDouble("lng"); loc.setLongitude(lng); loc.setLatitude(lat); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return loc; } } |
MapsActivity.java
This is Main Activity file to call the Layout file to build Map and define all required Radio Buttons for types like Atm etc.
|
package com.places.map.mapplaces; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RadioGroup; import android.widget.Toast; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.google.android.gms.location.places.ui.PlacePicker; import com.google.android.gms.maps.CameraUpdateFactory; 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.BitmapDescriptor; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.UiSettings; import com.google.android.gms.location.places.*; //important placepicker import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import static android.R.attr.key; import static android.R.attr.name; import static android.R.attr.radius; import static android.R.attr.type; import static android.R.id.list; import static android.R.interpolator.linear; import static android.icu.lang.UCharacter.GraphemeClusterBreak.L; import static android.icu.lang.UCharacter.GraphemeClusterBreak.V; import static android.media.CamcorderProfile.get; import static com.places.map.mapplaces.R.id.goatm; import static com.places.map.mapplaces.R.id.gobank; import static com.places.map.mapplaces.R.id.gobookstore; import static com.places.map.mapplaces.R.id.gocarrepair; import static com.places.map.mapplaces.R.id.gocarwash; import static com.places.map.mapplaces.R.id.godepartmentstore; import static com.places.map.mapplaces.R.id.gogym; import static com.places.map.mapplaces.R.id.gohospital; import static com.places.map.mapplaces.R.id.gopark; import static com.places.map.mapplaces.R.id.gopharmacy; import static com.places.map.mapplaces.R.id.goplumber; import static com.places.map.mapplaces.R.id.goschool; import static com.places.map.mapplaces.R.id.goshoppingmall; import static com.places.map.mapplaces.R.id.gotaxistand; import static com.places.map.mapplaces.R.id.gotemple; import static com.places.map.mapplaces.R.id.map1; import static com.places.map.mapplaces.R.id.placename; class MapsActivity extends FragmentActivity implements OnMapReadyCallback, View.OnClickListener { private GoogleMap mMap; private EditText placename; private CheckBox check1; private RadioGroup gradio; private Button nextbutton; private boolean nextpageflag=false; List<Marker> markers = new ArrayList<Marker>(); private String npage=null; Marker marker=null; private Button gobutton; int pzoom = 13; private String ptype = "restaurant"; String plocation = "28.6451,77.2938"; Location mlocation=null; String pkey = "AIzaSyCG1ucJwPFXTAJahYjpDn3ZotsQdI4eBg0"; String pname = ""; int pradius = 1500; Button goschool, goatm, gotourist, gofood, gobookstore,godepartmentstore,gotaxistand,goplumber,gorestaurant, gobank,gobakery,gogym,gotemple,goshoppingmall,gopark,gohospital,gocarwash,gocarrepair,gopharmacy; LinearLayout spinner ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_maps); setContentView(R.layout.activity_find_places); // 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); //context=this; goatm = (Button) findViewById(R.id.goatm); goschool = (Button) findViewById(R.id.goschool); gofood = (Button) findViewById(R.id.gofood); gotourist = (Button) findViewById(R.id.gotourist); gorestaurant = (Button) findViewById(R.id.gorestaurant); gobank = (Button) findViewById(R.id.gobank); gopark = (Button) findViewById(R.id.gopark); gohospital = (Button) findViewById(R.id.gohospital); gopharmacy = (Button) findViewById(R.id.gopharmacy); gotemple = (Button) findViewById(R.id.gotemple); goshoppingmall = (Button) findViewById(R.id.goshoppingmall); gogym = (Button) findViewById(R.id.gogym); gobakery = (Button) findViewById(R.id.gobakery); gobookstore = (Button) findViewById(R.id.gobookstore); gocarrepair = (Button) findViewById(R.id.gocarrepair); gocarwash = (Button) findViewById(R.id.gocarwash); godepartmentstore = (Button) findViewById(R.id.godepartmentstore); gotaxistand = (Button) findViewById(R.id.gotaxistand); goplumber = (Button) findViewById(R.id.goplumber); gradio = (RadioGroup) findViewById(R.id.gradio); spinner = (LinearLayout) findViewById(R.id.LProgress); check1 = (CheckBox) findViewById(R.id.check1); nextbutton = (Button) findViewById(R.id.nextbutton); placename = (EditText) findViewById(R.id.placename); gradio.check(R.id.goatm); goatm.setOnClickListener(this); gofood.setOnClickListener(this); goschool.setOnClickListener(this); gorestaurant.setOnClickListener(this); gobank.setOnClickListener(this); gotourist.setOnClickListener(this); gopark.setOnClickListener(this); gohospital.setOnClickListener(this); gopharmacy.setOnClickListener(this); gotemple.setOnClickListener(this); goshoppingmall.setOnClickListener(this); gogym.setOnClickListener(this); gobakery.setOnClickListener(this); gobookstore.setOnClickListener(this); gocarrepair.setOnClickListener(this); gocarwash.setOnClickListener(this); gotaxistand.setOnClickListener(this); goplumber.setOnClickListener(this); check1.setOnClickListener(this); nextbutton.setOnClickListener(this); // placename.setOnClickListener(this); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera // filldata1(this); setupMapUI(); } public void filldata(View view) { List<FindPlaces> arrlatlng = getdata(); if (arrlatlng != null) { LatLng pname = null; mMap.clear(); for (int i = 0; i < arrlatlng.size(); i++) { pname = new LatLng(arrlatlng.get(i).getLat(), arrlatlng.get(i).getLng()); mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); marker = mMap.addMarker(new MarkerOptions().position(pname).title(arrlatlng.get(i).getName()).snippet(arrlatlng.get(i).getVicinity())); marker.showInfoWindow(); //always show information CameraPosition cameraPosition = new CameraPosition.Builder() .target(pname) .zoom(15) .bearing(90) .tilt(60) .build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } showlocationmarker(); Toast.makeText(this, "Location Type:" + ptype, Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Location Not Found", Toast.LENGTH_LONG).show(); } } public void showlocationmarker() { BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.mylocationsmall); LatLng pname = new LatLng( mlocation.getLatitude(),mlocation.getLongitude()); marker = mMap.addMarker(new MarkerOptions().position(pname).icon(icon).title(placename.getText().toString())); marker.showInfoWindow(); //always show information CameraPosition cameraPosition = new CameraPosition.Builder() .target(pname) .zoom(15) .bearing(90) .tilt(60) .build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } private void setupMapUI() { // mMap.setMyLocationEnabled(true); UiSettings mUiSettings = mMap.getUiSettings(); mUiSettings.setMyLocationButtonEnabled(true); mUiSettings.setCompassEnabled(true); mUiSettings.setTiltGesturesEnabled(false); mUiSettings.setZoomControlsEnabled(true); } public List<FindPlaces> getdata() { BackgroundTask gp = new BackgroundTask(spinner); String str = null; String link = null; List<FindPlaces> arrstr = null; //get location mlocation = getlatlngnew(placename.getText().toString()); plocation = String.valueOf(mlocation.getLatitude()) +","+String.valueOf(mlocation.getLongitude()); Toast.makeText(this, "Location"+plocation, Toast.LENGTH_SHORT).show(); try { link = "https://maps.googleapis.com//maps/api/place/nearbysearch/json?location=" + plocation + "&radius=" + pradius + "&type=" + ptype + "&name=" + pname + "&key=" + pkey; str = gp.execute(link).get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } String[] fields = {"id", "name", "vicinity", "lat", "lng", "types"}; arrstr = gp.getplaces(str, fields,npage); return arrstr; } @Override public void onClick(View view) { if (view.getId() == R.id.check1) { if (gradio.getVisibility() == view.GONE) { gradio.setVisibility(view.VISIBLE); } else { gradio.setVisibility(view.GONE); } return; } if (view.getId() == R.id.goatm) ptype = "atm"; if (view.getId() == R.id.goatm) ptype = "Temple"; if (view.getId() == R.id.gobank) ptype = "bank"; if (view.getId() == R.id.gofood) ptype = "food"; if (view.getId() == R.id.goschool) ptype = "school"; if (view.getId() == R.id.gotourist) ptype = "tourist"; if (view.getId() == R.id.gopark) ptype = "park"; if (view.getId() == R.id.gohospital) ptype = "hospital"; if (view.getId() == R.id.gopharmacy) ptype = "pharmacy"; if (view.getId() == R.id.gotemple) ptype = "temple"; if (view.getId() == R.id.goshoppingmall) ptype = "shopping_mall"; if (view.getId() == R.id.gogym) ptype = "gym"; if (view.getId() == R.id.gobakery) ptype = "bakery"; if (view.getId() == R.id.gobookstore) ptype = "book_store"; if (view.getId() == R.id.gocarrepair) ptype = "car_repair"; if (view.getId() == R.id.gocarwash) ptype = "car_wash"; if (view.getId() == R.id.godepartmentstore) ptype = "department_store"; if (view.getId() == R.id.gotaxistand) ptype = "taxi_stand"; if (view.getId() == R.id.goplumber) ptype = "plumber"; gradio.setVisibility(view.GONE); filldata(view); } public Location getlatlngnew(String p_placename) { LocBackgroundTask gp = new LocBackgroundTask(spinner); String link = null; String str=null; Location loc= null; String psearchlocation=placename.getText().toString(); try { // link = "https://maps.googleapis.com//maps/api/place/nearbysearch/json?location=" + plocation + "&radius=" + pradius + "&type=" + ptype + "&name=" + pname + "&key=" + pkey; link = "https://maps.googleapis.com/maps/api/geocode/json?address="+psearchlocation+"&key=" + pkey; str = gp.execute(link).get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } loc = gp.getlocation(str); return loc; } } |
activity_find_places.xml
|
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_find_places" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="1dp" tools:context="com.places.map.mapplaces.FindPlaces"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.places.map.mapplaces.MapsActivity" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical"> <LinearLayout android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="30dp" android:orientation="horizontal"> <CheckBox android:id="@+id/check1" style="@style/style2" android:layout_width="30dp" android:layout_height="30dp" /> <EditText android:id="@+id/placename" style="@style/style2" android:layout_width="260dp" android:layout_height="wrap_content" android:background="@drawable/edittext" android:paddingLeft="15px" android:text="Gagan vihar,delhi 110051" /> <Button android:id="@+id/nextbutton" style="@style/style2" android:layout_width="30dp" android:layout_height="30dp" android:onClick="fnnext" android:text="V"> </Button> </LinearLayout> <LinearLayout android:id="@+id/LProgress" android:layout_width="fill_parent" android:layout_height="fill_parent" android:colorBackground="#000" android:gravity="center" android:orientation="vertical" android:visibility="gone"> <ProgressBar android:id="@+id/pbHeaderProgress" style="?android:attr/progressBarStyleLarge" android:color="#fff" android:layout_width="150dp" android:layout_height="150dp"></ProgressBar> </LinearLayout> </LinearLayout> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:colorBackground="#ff0"> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/style2" android:layout_width="300dp" android:layout_height="300dp" android:columnCount="3" android:gravity="center" android:orientation="horizontal" android:rowCount="2" android:scrollbars="vertical"> <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gradio" android:layout_width="fill_parent" android:layout_height="wrap_content"> <RadioButton android:id="@+id/gorestaurant" style="@style/style1" android:checked="false" android:text="Restaurant" /> <RadioButton android:id="@+id/goschool" style="@style/style1" android:checked="false" android:text="School" /> <RadioButton android:id="@+id/gofood" style="@style/style1" android:checked="false" android:text="Food" /> <RadioButton android:id="@+id/goatm" style="@style/style1" android:checked="false" android:text="Atm" /> <RadioButton android:id="@+id/gotourist" style="@style/style1" android:checked="false" android:text="Tourist" /> <RadioButton android:id="@+id/gobank" style="@style/style1" android:checked="false" android:text="Bank" /> <RadioButton android:id="@+id/gogym" style="@style/style1" android:checked="false" android:text="Gym" /> <RadioButton android:id="@+id/goshoppingmall" style="@style/style1" android:checked="false" android:text="shopp.Mall" /> <RadioButton android:id="@+id/gotemple" style="@style/style1" android:checked="false" android:text="Temple" /> <RadioButton android:id="@+id/gopark" style="@style/style1" android:checked="false" android:text="Park" /> <RadioButton android:id="@+id/gopharmacy" style="@style/style1" android:checked="false" android:text="Pharmacy" /> <RadioButton android:id="@+id/gohospital" style="@style/style1" android:checked="false" android:text="Hospital" /> <RadioButton android:id="@+id/goplumber" style="@style/style1" android:checked="false" android:text="Plumber" /> <RadioButton android:id="@+id/gotaxistand" style="@style/style1" android:checked="false" android:text="Taxi Stand" /> <RadioButton android:id="@+id/godepartmentstore" style="@style/style1" android:checked="false android:text="Dep.Store" /> <RadioButton android:id="@+id/gocarwash" style="@style/style1" android:checked="false" android:text="Car Wash" /> <RadioButton android:id="@+id/gocarrepair" style="@style/style1" android:checked="false" android:text="Car Repair" /> <RadioButton android:id="@+id/gobook_store" style="@style/style1" android:checked="false" android:text="Book Store" /> <RadioButton android:id="@+id/gobakery" style="@style/style1" android:checked="false" android:text="Bakery" /> <RadioButton android:id="@+id/gobookstore" style="@style/style1" android:checked="false" android:text="Book Store" /> </RadioGroup> </GridLayout> </ScrollView> </RelativeLayout> |
Style.xml
|
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="style1"> <item name="android:layout_width">100dp</item> <item name="android:layout_height">25sp</item> <item name="android:textColor">#ffffff</item> <item name="android:padding">1sp</item> <item name="android:layout_margin">1sp</item> <item name="android:textSize">12sp</item> <item name="layout_columnWeight">1</item> <item name="android:stretchMode">columnWidth</item> <item name="android:gravity">left</item> <item name="android:textStyle">bold</item> <item name="android:shadowRadius">10</item> <item name="android:shadowColor">#000</item> <item name="android:shadowDx">2</item> <item name="android:shadowDy">2</item> </style> <style name="style2"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#ffffff</item> <item name="android:typeface">monospace</item> <item name="android:textSize">13sp</item> </style> </resources> |
AndroidManifest.xml
|
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.places.map.mapplaces"> <!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use Google Maps Android API v2, but you must specify either coarse or fine location permissions for the 'MyLocation' functionality. <uses-permission android:name="android.permisssion.ACCESS_FINE_LOCATION"></uses-permission> <uses-permission android:name="android.permisssion.ACCESS_COARSE_LOCATION"></uses-permission> <uses-permission android:name="android.permisssion.INTERNET"></uses-permission> --> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <!-- The API key for Google Maps-based APIs is defined as a string resource. (See the file "res/values/google_maps_api.xml"). Note that the API key is linked to the encryption key used to sign the APK. You need a different API key for each encryption key, including the release key that is used to sign the APK for publishing. You can define the keys for the debug and release targets in src/debug/ and src/release/. --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyCG1ucJwPFXTAJahYjpDn3ZotsQdI4eBg0"/> <activity android:name=".MapsActivity" android:label="@string/title_activity_maps"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> |
Why the app stops after 4-5 seconds and doesn't show any place
ReplyDelete