Android Listview using Google maps - android

Iam building sample android app . Initially am displaying list with some cities.by clicking on any one of the city it will display map regarding to that city.
now am suffering with how to connect selected city from list with googlemap.any idea please let me know.

You simply make the list of city objects. Each object will contain the name of the city and the location (latitude, longitude). When you click an item, go to a map activity passing the location in the Intent object. In the map activity you'll parse the location and tell the map to go to that point.

Firstly, U have, for example database(or local data structure in your list activity) with cities and corresponding coordinates. Then, in onListItemClick() you create new intent and insert to it's extras necessary data (title, coordinates or primary key of the row in db table). Start new activity extended MapActivity with this intent, take mMapController = mMapView.getController(); and animate to mMapController.animateTo(new GeoPoint((int)yourLatitudeE6,(int)yourLongitudeE6)), where yourLatitudeE6 and yourLongitudeE6 - extras from intent

I think you should have lat and long of city .So you can send that lat and long to mapview through bundle and populate map of that city. In this link you can get complete tutorial for mapview . http://www.vogella.com/articles/AndroidGoogleMaps/article.html

Related

load map only single city on google map android

I want to show map only one city or country in my android app. How can I do it ?
I do not need to load map of all world
image 1
image 2
if you want to see only country or city you can use its latlng bound its focus on the particular city or country when user come first time here all country latlng bound https://gist.github.com/graydon/11198540
First, you have to be familiar with Google Map API (create an API key, import it to your project, etc.)
Then, get the LatLng of the city you want, and on the moveCamera method, pass to it a good zooming (it's a float). For exemple, when your widget is beeing launched, call something like : mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(yourCoords, 10f))
If you don't want / need to allow any user interaction with your map, just set the parameter "liteMode" to true inside your XML (or programatically), it will generate a bitmap of your desired location.
Bye.

Applying adapter concept in google maps Marker android

I populate my google maps with number of Markers based on my server data.
MY server data contains ProfilePic , Name , Designation , & lat long etc...
When I click on my Marker I open BottomSheet that display the details like ProfilePic , Name , Designation . just like google map does
I don't know how do I get ProfilePic and other data on click of my marker .
I am very familiar to Recyclerview adapter concept ,
How do I apply this concept to my marker ?
You can set custom adapters of infowindow for marker in google map.. check this example--http://androidfreakers.blogspot.in/2013/08/display-custom-info-window-with.html
Solution 1-> You can use HashMap for mapping of markers and your server data list.
Solution 2-> You can append the id or position to marker title with token(comma, semicolon...) and then onClick marker you can break them for further mapping to your server data list.
In this case you also need to override customInfoWindow.
Example to follow:-
http://devlearning.blogspot.in/2014/05/android-custom-info-window-with.html
Hope this may helpful to you
Thanks,
Bhuvnesh

Getting Google Maps Intent to Return Location

So I am trying to build an app that would allows the user to select a particular place from a Google Maps intent, and when the user pick a place, the intent would finish and return the latitude and longitude data to the previous activity.
What is the best way to do this?
What I have done so far:
I used GPSTracker from here.
to get the current latitude and longitude, and then used these data to start a google map intent pointing to current location.
The website you posted in your question does not look like it contains the actual map. If you need assistance with adding a Google Map to your application I would start here.
Assuming you have that working and your code allows a user to place his or her point already, you can retrieve the coordinates of that point by using a built in function in the Marker class getPosition().
You can use the coordinates by accessing the public variables .latitude and .longitude as follows:
LatLng coord = myMarker.getPosition();
double latitude = coord.latitude;
double longitude = coord.longitude;

Android Google Maps v2 testing

I have an activity that displays a list on markers based on the state of a model.
Whenever the model's state is changed, the markers are refreshed to display the new location or display any new markers.
I want to test this behavior but GoogleMap does not provide a .getMarkers() method or similar to know which markers are shown on the map.
The question is, how can I test both the number of Markers and the LatLng or each marker.
keep an ArrayList of all plotted markers and iterate through to find the one you want?
or there is a 3rd party mapping library that you can call getMarkers, getPolygons etc..
Thats just an idea but you can store you marker (latlng, id, image, etc) on an ArrayList. Then when you create your marker, assign foreach the id and on click retrieve the id to get all information's from your Array.

Dispalying route travelled using latitude and longitude values in map

I have an android app which will continuously send location information to server (latitude and longitude values). Another application will retrieve these info and display it in textview.
What I need to do is in my second app which displays in text view I need to add a mapview which displays the location tarvelled by marking it on map using the latitude and longitude values.
How to do it ? Thanks in advance !
As you have fetched the location information, now you just need to mark points on the map view to show the desired location on map view, You should follow using google maps android
Here you will find a good example on how to add markers on mapview.

Categories

Resources