In my android application i want to implement first person view. Please check following URL for first person View -
Google First Person View
I found one link which redirects to first person view please check -
Google Maps Navigation - Using Google Navigation in Android Application
But in it we don't have control over navigation view or first person view. It redirects to google's default first person view. I want to implement it manually. Means in which we can pass latitude and longitude dynamically(from Server)
Is there any way to implement first person view Pro-grammatically, in which we have command over view ?
Thanks in advance!
Don't know exactly, how to achieve that view, but you can do one thing, that is whatever orientation's value you are getting from your server or any gps device , pass it into bearing() method of CameraPosition and set tilt also, like following -
CameraPosition cameraPos = new CameraPosition.Builder().target(latlng)
.zoom(zoomvalue).bearing(orientation).tilt(tiltvalue).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), null);
by doing this your map will be rotate according to value of orientation. and if you pass value of orientation into rotation(orientation) method of marker then your marker will rotate according to value.
Hope it'll help you.
Related
I'm creating a small app that will help a user find a sports club. I'm currently creating a club coordinate variable in the MapsActivity.java file like so:
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng lansdowneRFC = new LatLng(53.3334103,-6.2201649);
// Adds location to the map (includes a small bit of info about the club)
mMap.addMarker(new MarkerOptions().position(lansdowneRFC).title("Lansdowne RFC").snippet("Aviva Stadium, 62 Lansdowne Rd,"));
}
This produces the following result
I'm trying to add a button to the information box that will bring the user to another activity (The activity will be a sign up form so they can join the club). Considering the approach I'm using is it possible to implement a button or will I have to approach it in another way? I've seen ideas like a custom popup window be suggested for this type of thing but how I implement that into a google maps marker instead of a button is where I'm hitting a brick wall. Any suggestions
You can set your own implementation of InfoWindowAdapter to your GoogleMap object with a call to setInfoWindowAdapter().
And in the adapter you can override getInfoContents() to return whatever view you want.
But the down side is the view that is shown is not a live view, it's an image of the view you created, and you can handle the click on it using a OnInfoWindowClickListener that you set on the GoogleMap object with setOnInfoWindowClickListener().
But that handles the click on the whole window, not just the button.
Another option is to know where your marker is at the screen and show a popup manually above it that has nothing to do with the map, but I would not recommend that approach, with Android's different device sizes and all, that could quickly get very ugly.
I made simple application where I get markers based on screen coordinates from the server. Problem is that markers doesn't appear on map immediately. User user must zoom in or zoom out only then marker is visible. Why is that? Is it possible to show marker as soon when marker data is downloaded from server? Or is it possible to somehow refresh map? I know that in previous version there was method map.invalidate() that is basically what I need to have now. Unfortunately this method is not available now.
I will add code snippet how my markers is added
#Override
protected void onPostExecute(ArrayList<MarkerItemData> markerItemData) {
super.onPostExecute(markerItemData);
if(markerItemData != null) {
mClusterManager.addItems(markerItemData);
}
}
It needs re-clustering again.
mClusterManager.addItems(markerItemData);
mClusterManager.cluster();
Because, when you add or remove an ClusterItem (MarkerItemData), it just performs the algorithm and calculates clusters. But does not render on map
Finally, ClusterManager listens onCameraIdle event(includes zoom events) and invokes cluster() method internally. This is the answer of user must zoom in or zoom out only then marker is visible.
From the javadoc here, you need to recluster your markers after adding them to your ClusterManager doing mClusterManager.cluster().
Forgive me for being new to android app building.
My plan is to build an app that would take a city and open a new activity for it. The problem is I really don't know how to go about that. My plan would be very similar to how the app yik yak does it where you go put a marker in a certain area and it brings you to the activity for that location. I believe yik yak only shows the ones that are close to you but my plan was to take you to an activity for that location. Is that possible to do it that way or should I take yik yak's route on it and only show things that are within a certain radius of you?
Where can I get started on learning how to do that?
First, you need to choose a provider for your maps.
I would say google map is a good start as you suggested in the tag, but beware, it might not be available on some Chinese devices without play services.
You can follow the documentation here for a quick start
https://developers.google.com/maps/documentation/android/
Regarding the number of pins you want to put on your map, I see no problem to display a lot of them, you just have to group markers as the user zooms out, so you don't have 10 pins overlapping themselves.
So if in a quite zoomed state, the user clicks a group of markers, you can display a dialog to choose the city.
If the user zooms in a lot and clicks a particular pin, then you can start an activity.
Your main concern is listening for a zoom level change, like that:
mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
private float currentZoom = -1;
#Override
public void onCameraChange(CameraPosition pos) {
if (pos.zoom != currentZoom){
currentZoom = pos.zoom;
// do you action here
}
}
});
Credits: https://stackoverflow.com/a/15046761/689710
Then, you can create a Map of Lists, the keys of the map will be the a custom lat / long object. Let's call it Pin. Pin provides it a custom isCloseTo method (taking a zoomlevel in params, and an other Pin object).
For each city you want to add on the map
For each key in the map
If the Pin object of your city isCloseTo the Pin key of the map
Add it to the list for that key
Else
Add a new Map entry with you city Pin as key and a list with your city as value
You Pin.isCloseTo method will be somehow similar to that:
https://stackoverflow.com/a/18170277/689710
Returning true or false according to "dist" return and your zoom level.
When you processed all your cities, you can browse the map and create a marker for each Pin key.
In a zoomed in state, you will have a Map with lists containing only one item, but i don't think it's much a problem.
You know yik yak is not starting a new activity when the place on the map is clicked. It rather updates the data underneath it when a new place is clicked. I think what you mean is you want to refresh/change the data displayed when a new city on google maps is clicked?
I am using the Google Maps API v2 and am trying to embed a reference ID to a marker info window. When a user clicks on the info window, it should pass the reference ID to a new intent.
I don't actually want the reference ID to be visible to the user. I added the reference ID as a snippet and use marker.getSnippet() to get the reference ID to pass to the new activity. Is there a way to hide the snippet so the user doesn't see it?
Customize the info window contents via an InfoWindowAdapter, attached it to your GoogleMap via setInfoWindowAdapter(). Implement onInfoContents() on the adapter to return something that does not contain your snippet.
I've been looking for the same thing and found something interesting myself.
The trick might seem so dumb but it worked perfect.
After getting the value from the Snippet in onMarkerClick(Marker m) I'm setting it back to null :D
Here is the code:
#Override
public boolean onMarkerClick(Marker marker) {
locationMarker = marker;
Intent intent = new Intent(getApplicationContext(),MarkerInfoView.class);
String uid = marker.getSnippet();
marker.setSnippet("");
intent.putExtra(UID,uid);
startActivity(intent);
return false;
}
So, on onClick() it shows the title and opens another activity and shows the related other information of the user there.
Give me crazy thumbzzup if it works for you ;)
Let me know if anyone need other coding help on tracking user and marker click operations.I'll try yo help as much as possible.
Good Luck (y)
Screenshot here:
I am trying to take advantage of an InfoWindowAdapter to provide custom content for the InfoView. I'm pulling down a JSONArray from my web service and adding the Markers but I'm not seeing how to pass the detail to the call back via a Marker.
#Override
public View getInfoWindow(Marker marker)
In the Javascript API I was able to just set arbitrary marker info. I want to be able to pass info that can be used as conditionals for the custom content, example a marker.status string. So something other than title etc. The view will need a number of custom fields I need to pass in.
perhaps try adding your info or object to the marker as explained here:
http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html
Edit: I also made a post that continues the previous to use the InfoWindowAdapter.
Check it out here!