{"id":7076,"date":"2014-05-19T04:12:24","date_gmt":"2014-05-19T04:12:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/implement-map-search-function-on-custom-application-like-in-native-google-maps-collection-of-common-programming-errors\/"},"modified":"2014-05-19T04:12:24","modified_gmt":"2014-05-19T04:12:24","slug":"implement-map-search-function-on-custom-application-like-in-native-google-maps-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/implement-map-search-function-on-custom-application-like-in-native-google-maps-collection-of-common-programming-errors\/","title":{"rendered":"Implement map search function on custom Application like in native google maps-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<p>By Name og Location<\/p>\n<pre><code>public void searchPlace()\n{       \n\n    AlertDialog.Builder alert = new AlertDialog.Builder(this);\n\n    alert.setTitle(\"Search Location\");\n    alert.setMessage(\"Enter Location Name: \");\n\n    \/\/ Set an EditText view to get user input \n    final EditText input = new EditText(this);\n    alert.setView(input);\n\n    alert.setPositiveButton(\"Ok\", new DialogInterface.OnClickListener() {\n    public void onClick(DialogInterface dialog, int whichButton) {\n      String value = input.getText().toString();\n      \/\/ Do something with value!\n      Log.d(\"value\", value);\n\n      Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());    \n        try {\n            List addresses = geoCoder.getFromLocationName(\n                value, 5);\n            String add = \"\";\n            if (addresses.size() &gt; 0) {\n                p = new GeoPoint(\n                        (int) (addresses.get(0).getLatitude() * 1E6), \n                        (int) (addresses.get(0).getLongitude() * 1E6));\n                mc.animateTo(p);    \/\/ create mapController object like `MapController mc = mapView.getController();`\n                mapView.invalidate();\n            }    \n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n\n\n      }\n    });\n\n    alert.setNegativeButton(\"Cancel\", new DialogInterface.OnClickListener() {\n      public void onClick(DialogInterface dialog, int whichButton) {\n        \/\/ Canceled.\n      }\n    });\n\n    alert.show();\n\n}  \n<\/code><\/pre>\n<\/li>\n<li>\n<p>By LAtLang.<\/p>\n<pre><code>public void byLatLang()\n{       \n\n    LayoutInflater factory = LayoutInflater.from(this);            \n    final View textEntryView = factory.inflate(R.layout.latlong, null);\n\n    AlertDialog.Builder alert = new AlertDialog.Builder(this);\n\n    alert.setTitle(\"Search Location\");\n    alert.setMessage(\"Enter Lattitude and Longitude: \");\n\n    alert.setView(textEntryView); \n    \/\/ Set an EditText view to get user input\n    AlertDialog latLongPrompt = alert.create();\n\n    final EditText lat = (EditText) textEntryView.findViewById(R.id.lat);\n    final EditText longi = (EditText) textEntryView.findViewById(R.id.longi);\n\n    alert.setPositiveButton(\"Ok\", new DialogInterface.OnClickListener()   {\n    public void onClick(DialogInterface dialog, int whichButton) {\n\n        Toast.makeText(getBaseContext(), \"clicked ok \", Toast.LENGTH_SHORT).show();\n      Double value1 = Double.parseDouble(lat.getText().toString());\n      Double value2 = Double.parseDouble(longi.getText().toString());\n      \/\/ Do something with value!\n                  \/\/Log.d(\"value1\", value1);\n          \/\/Log.d(\"value2\", value2);\n\n      p = new GeoPoint(\n                (int) (value1 * 1E6), \n                (int) (value2 * 1E6));\n\n            mc.animateTo(p);\n            mc.setZoom(17); \n            mapView.invalidate();\n\n\n      }\n    });\n\n    alert.setNegativeButton(\"Cancel\", new DialogInterface.OnClickListener() {\n      public void onClick(DialogInterface dialog, int whichButton) {\n        \/\/ Canceled.\n      }\n    });\n\n    alert.show();\n\n}  \n<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>By Name og Location public void searchPlace() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(&#8220;Search Location&#8221;); alert.setMessage(&#8220;Enter Location Name: &#8220;); \/\/ Set an EditText view to get user input final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton(&#8220;Ok&#8221;, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); \/\/ Do something with value! [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7076","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7076"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7076\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}