I donβt think the marker is actually on GoogleMap in the case of Pokemon Go. If you want to fix the image (or any view) in the center of the map ... Just make sure the image is in the center of the map in your XML file.
Like this:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@mipmap/ic_self_position"/> <fragment android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/> </RelativeLayout>
So now you have a marker in the center of the map. Good, but you are still not in sync with the user's position ... So allow this.
I am going to assume that you have no problem launching your card. So do it, I'll wait. Are you done? OK. Set of cards.
Just remember to turn off drag and drop on the map:
@Override public void onMapReady(GoogleMap googleMap) { googleMap.getUiSettings().setScrollGesturesEnabled(false); ... }
Let me get the user's location and move the map.
Using this link:
https://developer.android.com/training/location/receive-location-updates.html
But change the piece of code to this:
public class MainActivity extends ActionBarActivity implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener { ... @Override public void onLocationChanged(Location location) { mCurrentLocation = location; mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); moveUser(Location location); } private void moveUser(Location location) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); mCharacterImageView.animate(pretendThatYouAreMovingAnimation) [you can make a animation in the image of the user... like turn left/right of make walk movements] } }
If you want to rotate your symbol in the direction of movement, you will need to compare the previous Latlng with the new one and rotate the image (or see ... or something else) to indicate the direction of movement.
If you need more information, maybe this repo can help you: CurrentCenterPositionMap
(The repo does not do what you want ... it uses only the same concept of my explanation.)
Leandro borges ferreira
source share