I want a Map UI like above dotted circle route path .I searched a lot through web and stack overflow i cant find any source.
I tried
addCircle polyline but the circle is large when i zoom the camera to
an extend in google map
I don't know how google map implemented it either with marker or
polyline
Provided help is appreciated rather than downvotes!!
thanks :-)
You can use Stroke Patterns for polylines like this:
#Override
public void onMapReady(GoogleMap googleMap) {
List<LatLng> sourcePoints = new ArrayList<>();
sourcePoints.add(new LatLng(22.724526, 75.825979));
sourcePoints.add(new LatLng(22.720165, 75.905953));
sourcePoints.add(new LatLng(22.766649, 76.075773));
sourcePoints.add(new LatLng(22.862032, 76.098302));
PolylineOptions polyLineOptions = new PolylineOptions();
polyLineOptions.addAll(sourcePoints);
polyLineOptions.width(50f);
polyLineOptions.color(Color.rgb(0, 178, 255));
Polyline polyline = googleMap.addPolyline(polyLineOptions);
List<PatternItem> pattern = Arrays.<PatternItem>asList(new Dot(), new Gap(10f));
polyline.setPattern(pattern);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(sourcePoints.get(2))
.zoom(14)
.build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
to get result like that:
Unfortunately it's impossible to draw bigger circles under smaller to achieve "bordered" circles path because of nonlinear dependency between Dot() and Gap() sizes.
Or you can draw whatever you want on MapVew canvas via overriding dispatchDraw() of MapView like in this answer (it's about MapBox MapView, but approach is applicable for Google Maps MapView too).
I think its overkill, but you can use some of Google APIs from https://console.developers.google.com/apis/library
and get path and make from them set of LatLngs, then draw them on googleMap just like normal marker, but with small round circle as icon.
To be honest, I am not sure what you want to achieve, I think simpler idea is to use origin and destination and open it in GoogleMaps Android App - do not reinvent the wheel.
Related
Anybody knows how to create a polyline/polygon around building or specific place as shown in above image using google map api v2.
Thanks in advance.
Get the Latitude and Longitude of required points and use below code to draw polygon.
GoogleMap map;
// ... get a map.
// Add polygon in the area
Polygon polygon = map.addPolygon(new PolygonOptions()
.add(new LatLng(Lat1, Lon1), new LatLng(Lat2, Lon2), new LatLng(Lat3, Lon3), new LatLng(Lat4, Lon4))
.strokeColor(Color.RED)
.fillColor(Color.BLUE));
Its up to you to get the required Latitude and Longitude of targeted area
I am recording coordinated inside onLocationChanged() and drawing polylines between each to create the route taken by the user. But sometimes the polylines extend to infinity and off the screen as seen here. They disappear at certain zoom levels but reappear when you zoom back in. Below is the code used:
map.moveCamera(CameraUpdateFactory.newLatLng(driver));
routePoints.add(driver); // driver is location object
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.color(Color.RED);
polylineOptions.addAll(routePoints);
map.addPolyline(polylineOptions);
Hi I have created a map as well as some markers which indicate places/locations on the map. Is there any possible way of creating an animation between those location? For instance drawing a polyline between 2 different locations and create an animation from a start point to an end point ? Is there any documentation for such a thing or any tutorials ? Many thanks.
Something like this:
https://www.youtube.com/watch?v=HPWYorS68WE
use this code and you can also follow this link
https://developers.google.com/maps/documentation/android/
Flat Markers
LatLng mapCenter = new LatLng(41.889, -87.622);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 13));
// Flat markers will rotate when the map is rotated,
// and change perspective when the map is tilted.
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.direction_arrow))
.position(mapCenter)
.flat(true)
.rotation(245));
CameraPosition cameraPosition = CameraPosition.builder()
.target(mapCenter)
.zoom(13)
.bearing(90)
.build();
// Animate the change in camera view over 2 seconds
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
2000, null);
}
I am developing an android application to trace the device movement.I am able to get the current location but how can i draw the route with set of points collected during trip
Define List for all points.
List< LatLng> points = new List< LatLng>();
//Add all points in list
points.add(new LatLng(lat1,lng1)); // POINT1
points.add(new LatLng(lat2,lng2)); // POINT2 and so on.
// then define PolylineOptions
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.addAll(points);
Polyline route = googleMap.addPolyline(polylineOptions);
// for marker use MarkerOptions
Use something more reliable than drawing a route: Markers.
Check the google maps Sample application from the Android SDK, and take a look on the MarkerDemoActivity.java class.
Open eclipse:
New Project->Android Sample Project->[YOUR_BUILD_TARGET]->maps [Google Play Service]
This will give you a good idea about what you're trying to search for.
Here's an example of what you'll get:
I have a List with LatLng objects that form a route I want to draw on my map. I am using a SupportMapFragment and I call this method below on onActivityCreated. I have another method called from there that creates markers and that one is executed fine but my method below does not draw the polyline. I have searched for examples but could not find any that suit my needs. Can someone please point out what I'm doing wrong here?
private void drawRoute() {
List<LatLng> latLngs = CoordinateEntity.getRouteLatLngs();
PolylineOptions line = new PolylineOptions();
line.width(5);
line.color(Color.RED);
for (LatLng latLng : latLngs) {
line.add(latLng);
}
getMap().addPolyline(line);
}
I have looked at this and other similar examples and all follow this code pattern
mMap.addPolyline(new PolylineOptions()
.add(new LatLng(lats, lons), new LatLng(late,lone))
.width(5)
.color(color));
Is this the only way a Polyline can be added to the map?
Found my problem.
I had the play services jar added to my project and for some reason everything of the maps V2 api worked except drawing lines.
I then added the play services project as a dependency and after I did that everything worked.