Putting map marker in non map activity - java

I'm new android developer and i'm trying to develop application follows the user movement in particular location with rounded path and count how much rounds he did. I want to do this in an Activity not in a MapActivity
any ideas?
Update:
http://s23.postimg.org/5230j4tnf/image.png
this what i'm trying to do
i want the small dot track the user movement in circular path that he should walk around then count the rounded he did

you could use the LocationManager and get the fine location, and then use that latitude and longatude to manually figure out where that maps to on your circle based on the lat and long of the edges of the path on google maps, and plot an image view of a map pointer there. This is a very round about way of doing it, but in theory it could work.

Related

Android - Is it possible to make a navigation on a .png?

I get a lat long from the backend and I want to use a PNG as a map, because this map is self made. So I want to transfer my lat long on this PNG and then draw at this position a point, but I couldn't figure it out how to do...
I couldn't find it here in another question. Maybe it's so easy that no one ever asked this.
I am new to Android and new to stackoverflow :)
EDIT because of comment: The image is a self made map. It was made with ESRI cityengine and Blender. Then I made a birdseye-screenshot of the map and this screenshot I want to use as my map.
EDIT 2: #MarkusKauppinen made a good comment! So I also want to convert the lat/long to x/y coordinates of the screen (like (How do android screen coordinates work?) ). But the lat/long of my backend don't relate to the lat/long of the Earth.
Even thought that this question has a downvote and probably no one will ever see it, I could figure it out how to solve my problem.
I used this Canvas Bitmap Method to draw the map on my screen. Then I converted the lat/long coordinates so that they fit on the Screen of the mobile phone with the help of this post: How do android screen coordinates work?
With the converted lat/long coordinates then I could draw a circle on the current position on the map. Now when the coordinates change the circle is moving like it should.

Pointing to a location in Google Maps in Android Studio

I am working on an app using android studio where cell data is saved in a database with it's corresponding location in latitude and longitude coordinates and users can access this data when there is no service to find a way to a good to better service. The data will be drawn to a google maps activity and color coordinated to represent the color but I also want to add an arrow the points from current location to the best cell service within a radius that I will set up.
Is it possible to draw an arrow to accomplish the task of pointing to a data point that is drawn? any info that points me in the right direction or the answer will help, thank you.
EDIT
The arrow design I have in mind points to the better signal but does not connect to the other location. I will figure out a more complex pointing device later in development so I am just looking for information on the possibility of a short pointer arrow that represents a "GO THAT WAY" response.
You can use Ground overlays , where you can set particular image at given latlong.
LatLng NEWARK = new LatLng(40.714086, -74.228697);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
.position(NEWARK, 8600f, 6500f);
map.addGroundOverlay(newarkMap);
for rotating the image you can look
https://stackoverflow.com/a/4332278/7386743
Are you talking about creating line between the two points ? Could you clearify more what do you exactly need ?
If it creating a line then you can use polyline
GoogleMap map;
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
.width(5)
.color(Color.RED));

Android - How can I achieve this Google Maps animation?

This is how I'm currently using my google map;
mapFragment = ((SupportMapFragment) getChildFragmentManager()
.findFragmentById(R.id.map)).getMap();
mapFragment.setMyLocationEnabled(true);
mapFragment.setMapType(GoogleMap.MAP_TYPE_HYBRID);
mapFragment.getUiSettings().setMapToolbarEnabled(false);
mapFragment.getUiSettings().setScrollGesturesEnabled(false);
mapFragment.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
It produces a full screen map which for some reason is completely zoomed into the ocean so the map is just one big, blue pixel until you keep zooming out.
What I want to do:
When this activity gets opened, the map should have the user's location in the center, and the map should be as zoomed out as possible (as if you are lookin at a 2D globe)
The map should then zoom/animate into the player's location to give the same effect as when you press the location button on the top right of the map.
I have looked online, tried a few things and haven't had any luck with this. If anybody can walk me through this or give me a link to a nice guide it would be highly appreciated!
To achieve what you want, you should:
1) get the user's position, you can use the last known position so that your main activity would not hang and wait for the GPS return a location.
LocationManager locationManager = (LocationManager)getSystemService
(Context.LOCATION_SERVICE);
Location getLastLocation = locationManager.getLastKnownLocation
(LocationManager.PASSIVE_PROVIDER);
2) set the zoom level to 1, which is the smallest zoom level, the 2D globe; also you can center the map using the user location too.
googleMap.moveCamera(CameraUpdateFactory.zoomTo(1));
3) animate the camera to zoom into the user location with a zoom level 20 (the largest zoom level). One thing to notice is that, you might want to wait until the 2D globe maps is loaded so that user can see the zoom happens.
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
public void onMapLoaded() {
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
.target(new LatLng(userLocation.getLatitude(), userLocation.getLongitude()))
.zoom(20)
.build()));
}
});
I tried that and it works fine for me. Let me know if it is unclear, and hope it helps.

Generating Bitmaps with custom text for map markers - OutOfMemoryError

I have a mapview that displays your route traveled in a car, and has a seekbar that allows you to move along the path, displaying a map marker at each location with the speed on it. These map markers (Bitmaps) are generated at run-time since the speeds need to be placed on them. The problem I am having is that a trip may have hundreds of locations that require a new map marker/ Bitmap to be generated. I am currently creating a new bitmap for each location in an AsyncTask. For a long trip, the app force closes due to an OutOfMemoryError. I need a way to swap out the text on the map markers so that I can create 1 Bitmap.
Any help/advice is greatly appreciated.
Bipmaps are always a expensive operation when it comes to mobile development. What I would suggest you is to have a lazy loading of marker (Bitmaps). So, what you can do is first know the visible area and the bounds corresponding to that and fetch markers only when the map is scrolled in that region. This wont consume a lot of your memory at run-time and would fetch bitmaps only when needed.
Here is a sample code:
GoogleMap = theMap;
LatLngBounds bounds = this.theMap.getProjection().getVisibleRegion().latLngBounds;
LatLng placeLL = new LatLng(yourLatitude, yourLangtitude);
if (bounds.contains(placeLL)) {
//Do what you wanted to do with the markers inside the visible area
}
Hope this Helps!!

How to create a Location arrow Marker with Sensor bearing in Android Google Maps v2?

I have managed to create an arrow ImageView and get the azimuth from the sensors, after that I rotate the ImageView using setRotation() method of the View class. How I can do this for a marker using Android Google Maps v2 Markers?
I suggest you take a look at the android-maps-utils project from Google.
It contains
BubbleIconFactory : Responsible for generating markers
RotationLayout : Responsible for rotating the contents of the layout (the marker) by multiples of 90 degrees
This should give you the building blocks you need to display your arrow/marker and give it a certain rotation. You'll probably need to customize the rotationlayout a bit.
you can use:
https://developers.google.com/maps/documentation/android/marker#rotate_a_marker
com.google.android.gms.maps.model.Marker marker = addMapMarker(camera,PrefManager.getCurrentUsername(getActivity()),
BitmapDescriptorFactory.fromResource(R.drawable.overlay_gps_location_scanner_icon));
marker.setRotation(0);

Categories

Resources