i am creating a app which offers a service for place to register and store general details and their location then I'd like to retrieve these places locations on the Android app ,based on the user's location, So that when a app user open the app, the registered place near that user in a 5 mile radius is listed or shows on map
Kindly provide the useful solutions or links related to such scenario.
thanks
You can use markers to add locations in google maps. https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker
Google lists everything here. They also have a sample app on Github here. I'd suggest starting a sample map activity project in Android Studio, it should help you understand the basics of implementing a Google Map in your project.
GoogleMap map = ... // get a map.
// Add a marker at San Francisco.
Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(37.7750, 122.4183))
.title("San Francisco")
.snippet("Population: 776733"));
Related
I am trying to use the Bing Maps SDK to display a map in which I show a SearchView. In this SearchView I want to search for locations and when I click on a suggested location, put a marker on the map at that location.
I have previously used the HERE SDK which has a documentation to do this but on Android I can't find any documentation about this Bing Maps SDK.
What I want to achieve is this in Android: https://www.bing.com/api/maps/sdk/mapcontrol/isdk/autosuggestui#TS
Documentation on Bing Maps autosuggest service can be found here: https://learn.microsoft.com/en-us/bingmaps/rest-services/autosuggest
You can use this with Androids AutoCompleteTextView to create a suggestion UI. You will retrieve the suggestions asynchronously from the above service. Here are a few good samples:
https://www.truiton.com/2018/06/android-autocompletetextview-suggestions-from-webservice-call/
How to implement autocompletetextview in Android Studio with an API call?
This service does not return coordinates. This is done so that it isn't used as a replacement for the geocoding service and thus allows them to make this a lower cost service. When a suggestion is selected by the user, you will need to make a single call to a geocoder to get the coordinates of the formattedAddress, then you can use that to display a marker on the map. I recommend setting the result limit to 1 since you only want to top result.
In summary;
Use addTextChangedListener event of AutoCompleteTextView to retrieve suggestions from the autosuggest service.
Use setOnItemClickListener event of AutoCompleteTextView to retrieve the selection from the user, and pass the formattedAddress value into the geocoding service.
Use the coordinates from the geocoder response to create a marker and add to the map.
I am facing a problem while i am developing an application Using Google maps SDK.
I am creating dynamically some markers on the map, but these markers are quite big (using custom marker image and label above them).
But when i try to tap on a specific marker many times it selects the very next to it.
The accuracy of the click is not perfect and more over some times i need to click twice in order to get the click event get fired.
Making a google search i found that there are some issues with google maps sdk markers.
Is the issue being caused because of the size of the markers?
You can you marker options like this.
MarkerOptions lMarkerOpt = new MarkerOptions()
.title("Title")
.draggable(true)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.position(YourLatLng)
.snippet("Title");
It will use default marker with whatever color you want.
I'm making an application where the user can create a set of markers and then have the option to export them in some sort of file, so that not only can the map (with the markers) can be saved and reopened, other people using the app can import this file into their application.
At the moment, every time I create a marker, I add the marker object to an arrayList. Here is the code for that:
List<Marker> markers = new ArrayList<Marker>();
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(lati, longi))
.title(title)
.snippet(snippet)
.draggable(true));
markers.add(m);
This seems to work reasonably well; I am able to get the properties of each marker through methods such as getTitle() or getSnippet() etc.
However, everytime the activity is destroyed, this contents of this arrayList disappears as well, thus I feel as though I need to save this information is some file. Here are my questions:
Is saving objects in a text file a good idea? Or should I save strings and integers (only the info i need, rather than the whole marker) and use something else instead of textfiles (sharedprefences maybe?)?
How would I be able to do this? Examples for the export and import functions of all the markers would be really helpful.
Whenever I rotate the device, the activity is destroyed, thus all the info is gone. Will i have to export and import everytime this happens?
Any help or insight to any of these questions would help a lot :)
you can use content provider for sharing data between app.
see this https://developer.android.com/guide/topics/providers/content-provider-creating.html
for avoiding to refresh after screen rotation add this line to your manifest file
android:configChanges="keyboardHidden|orientation|screenSize"
I'm developing an android application in which I've used Google Map v2 API.
I've placed one marker on the map, now I want to set its "OnLongClickListener".
As I can see from Eclipse there are only two listeners available for marker:
googleMap.setOnMarkerClickListener(listener);
googleMap.setOnMarkerDragListener(listener);
Could anybody show me any easy way to handle marker's LongClick event??
I've gone through two solutions here:
Setting a LongClickListener on a map Marker
How to detect long click on GoogleMap marker
as both of the solutions you posted have shown - there is no long click event on markers in the maps api. the first link you posted had a solution that might be able to suit your needs but isn't perfect by any means
i would suggest going here to the gmaps issues page and browsing through the feature requests and adding one if it does not exist
i'm new to google maps api V2. I want a functionality like, on the page it has to display the map and there has to be a marker in the map and the map has to be draggable and by dragging it has to display the dragged location's latitude and longitude.. Can anyone plz help me to solve
Take a look at the docs... https://developers.google.com/maps/documentation/android/marker#marker_drag_events
To get the final position, just call marker.getPosition() in the onMarkerDragEnd method.