I wonder,
how can I draw a nice flight route between 2 points on a google map's
MapView?
look at this:
http://maps.forum.nu/gm_flight_path.html
this is exactly what I need.
thanks!
Look at my reply to question
How to draw a path on a map using kml file?
and there especially into the RouteOverlay class / draw method.
Since you only want to draw a simple straight line, you probably won't need the rest of the complexity there.
Related
I have been working on nutiteq maps, and I need to draw a trace over map, as my location changes, but it should be with different width(5m, 10m) and need to calculate where its overlapping itself. I draw lines dinamicly with line.setVertexList(arr_lat_long), but I think that this isn't an good approach to do this job. Think to draw them like a polygons, because then will calculate overlapping with JTS. But it will be very slow operation :/. Is there an another way to draw over the map, some other paint tool or lib to help me. The purpose is to fill some area with these traces..
Thanks
I have a MapView (provided by Google Maps Android API v2) and what I'm trying to achieve should be simple enough, which is simply to draw a curved Polyline.
To be specific, I have an array of LatLngs and rather than having them joined at sharp angles, I want to have the route rounded off nicely, so that the line through the points follows a curve rather than straight lines and sharp angles.
Now, this used to be possible in the old Google Maps API by creating a custom Overlay, overriding draw(), and then manually drawing onto the map (e.g. with a custom Paint and Path with the desired settings).
Unfortunately it seems that in v2, Google have removed the Overlay class and moved to higher-level abstractions which no longer provide access to the draw() method. PolylineOptions is fairly basic and doesn't provide any option to draw a curved line.
Is there any way to override draw() or use other features of Google Maps API v2 in order to draw a curved Polyline?
There are a few questions already on SO which cover this issue, however there isn't really a satisfactory answer as yet:
Custom Overlays in Google Maps API v2
Overrinding draw() in customized MapView in Google Maps Android API v2
I'm sure there must be a way to do custom drawing on Google Maps v2, and whilst creating a custom overlay View and drawing onto that once the coordinates are synced up with the map is an option, it will quickly get extremely complicated when dealing with scaling and panning the map, so it's something I want to avoid if at all possible.
I have developed an abstract class CanvasTileProvider() where you just have to override the onDraw method, in order to perform your drawing as usual into a Canvas. A TileProjection object, which is passed into the onDraw method in addition, helps you to do the back and forth calculation between LatLng and points on the Canvas.
The only limitation is, that tiles are usually loaded only once. So this way of drawing into the map is suitable for shapes which do not frequently change. Thus it may not be suitable if your array of LatLng objects is continuously changing (e.g. because it shows the current movement of the device).
You can find the CanvasTileProvider class in the answer to this SO question
Can anyone, help me draw a circle or rather precisely an Arc with a given center point (GeoPoint) and the start and end points as well. So basically, it should help me draw a sector with given center point along with start and end points. I'm planning to use PathOverlay as my baseclass from OSMdroid, so that it would be easier for me to remove or add.
I understand the greatCircle provided in PathOverlay of OSMdroid, but not quit sure how to make use of it, I was wondering if any sample example be provided. Also How would I set the center of this GreatCircle.
Don't use a PathOverlay to draw filled polygons: as you noticed, this doesn't work properly when portions of the polygon are outside the screen.
for filled polygons, use an OSMBonusPack Polygon.
For setting the points of your arc, there is no ready-to-use API currently.
A "great circle" on a map represents the shortest "as the crow flies" path between two points. It is going to look like a straight line on your map. You need to think of the Earth as a sphere when considering the centre of the great circle; the centre is of course, the centre of the Earth.
I want to draw something like this:
gooogle maps example
but using osmdroid with OpenStreetMaps.
I have a set of GPS points prepared but I cannot find ay working example
Has anyone done this?
PathOverlay will not do the job properly: it has been optimized for drawing lines, and this is causing issues when using it for filled polygons (when the polygon is partly inside the view, and partly outside).
You can use the OSMBonusPack Polgon overlay.
A PathOverlay will give you the polygon. You may have to extend PathOverlay to create the fill color.
I am writing a application that needs to draw a "route" comprised of lots of GPS points (long+lat). The points are close together and don't follow roads, simply drawing a line between each point is ideal.
The current implementation I have is very slow as I am looping over all the GPS coordinates and creating a new Point and overlayitem in an itemized overlay. This takes around 20 seconds for it to load all of these points and draw them to the mapview. Is there a way in which I can construct a series of lines or point from the GPS coordinates and draw them onto the mapview?
Example of current implementation:
for each set of long+lats // removed to simplify
point= new GeoPoint(latitude,longitude);
overlayitem = new OverlayItem(point,"","");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
mMapController.setCenter(point);
Thanks in advance, hope I've explained it well enough.
Check my reply with code sample here:
How to draw a path on a map using kml file?
This example parses a kml files (xml format as provided by Google Maps or Google Earth for route calculation) and draws the geo points onto the map. If you already have a list of geo points, you can just look at the drawPath() method; and adjust the way you pass the geo coords parameters to it (I encapsulated it into a simple bean that I named NavigationDataSet).
It's not entirely clear to me what you're doing because I'm not sure how itemizedOverlay is drawing between the points. But I bet the primary problem is that you're using a bunch of OverlayItems when it'd be much faster to just skip that part entirely and override the itemizedOverlay's draw() method. I've done this before and it works quite well for line drawing. The basic pseudocode is:
create List of GeoPoints
add List to ItemizedOverlay
add a dummy marker to ItemizedOverlay (so that it knows to call `draw()`)
in ItemizedOverlay.draw(), use mapView.getProjection() to map the array of GeoPoints to x,y coords
use Canvas.drawLines() to draw a line between all your points
Since speed is a concern, make sure to create the Paint objects in the ItemizedOverlay's constructor; they can be reused as much as you want.
Also as a side note, it looks like you're using addOverlay() as demonstrated in the Hello, MapView demo. The only problem with using that is that they call populate() each time you add an item; if you are adding a bunch of points, it's better to add a bunch of overlays at once then call populate() at the end.