Search code examples
androidgoogle-mapssearchview

get current map location when open android searchView widget


Im using this code http://wptrafficanalyzer.in/blog/android-searchview-widget-with-actionbarcompat-library/ to use the autosearch for map positions. I would like to open the map with my current actual position. Meaning before i open my map activity i need my current location. how do i doo this? Thanks!!


Solution

  • If you are using Google Map API V2 then use this method. It will display my location button on map.

    googleMap.setMyLocationEnabled(true);
    

    or you can add marker on map using your current lat-long.

    API Document

    Example