Android Map View Issue - android

I am having an app which tracks the Geopoints of the user. I simply fetch these points and use them to draw the path on Map View.
My issue is, when I see the path tracked by user, the path seems to be correctly plotted but, when I have a first look over the map,it does not show me an entire zoomed out view of the map where I can see all the track path. Instead the map begins with from where I started tracking and then I need to scroll all my way to see the further tracks.
Please Help. :)
Thanks In Advance.

Use MapController.zoomToSpan(...), you can get the span from your ItemizedOverlay methods getLatSpan(int) and getLonSpan(int). zoomToSpan(...) is a best effort method and does not guarantee that all points will be visible.

Related

How to clear coordinate where i want on google maps API v2

I made polygon on maps fill black and tried to clear current location use addHole method.
But if holes overlap each other, polygon with holes appear i don't want!
Please give me answer...
http://i.stack.imgur.com/jn15M.jpg
http://i.stack.imgur.com/RajLA.jpg
Plus, Is there exist a way clear the polygon given gps coordinate??
Thanks
You can use TileOverlay.remove() method to remove a tile overlay or use tileOverlay.clearTileCache(); to force a refresh. This will cause all the tiles on this overlay to be reloaded. If the tiles provided by the TileProvider change, you must call clearTileCache() afterwards to ensure that the previous tiles are no longer rendered.

Drawing on the MapFragment, while keeping some elements visible

I'm developing an application that has the following goal:
Using the google maps android API 2 I get my current position, and as I start walking the application starts drawing the route I take
The twist is that the map is a "blind" map. Meaning the map is hidden, only the Marker of my current position and a dotted line of my route is shown.
Keep in mind I'm a novice developing to Android, so please be specific. (Thank you)
I managed to create the map, get my current position and zoom in to it (Had no sens to see the whole planet while i want only my current position). And it's pretty accurate so far.
The thing is I don't know what should I do from this point on.
Basicly I need a white View between the Marker and the real map. Also as I advance that View should always be on, over the MapFragment/MapView. Also I wish to keep the zoom and drag functionality's of the MapFragment.
How can I achieve this?
At this point I'm opened to any solutions.
(Been browsing for a few days now the developers site, I have seen that with the ViewOverlay class I can put messages over the map, but I'm not sure what would the correct aproach be in my case...)
To hide the whole map behind the white view I would use Polygon class Polygon Even if you specify Polygon to cover the whole map Markers will be still displayed in front of it and as so user's current position marker will be visible. You also will be able to zoom and drag.
To draw line on map use Polyline class Polyline It will draw users path as a polyline. If you want to stick with dotted line you can use Circle objects to create it. Circle

Possibles to draw route in MapView

I'm trying to do a route in MapView, I research and just find ways I need to draw lines like this: http://androidpallikoodam.wordpress.com/2012/04/04/draw-google-driving-directions-in-mapview-overlay/ , I try use this but doesn't work very well, google send me just few points so when I draw route stay wrong (or have anyway can I request more points to Google?).
I'm thinking and have anyway can I load MapView with different URL, like http://maps.google.com/maps?saddr=brighton&daddr=timbuktu because if I call a new intent with this url and put this in Map from Android, the route is displayed so if I can load my MapView with this URL, maybe work.
Other option is show entire application Maps on mine Activity, so I can put other things like buttons and labels, understand? What I'm trying to say is put one application installed on android for running in a determined area on my screen. this is possible?
anyone can help me?
Thanks.

Zooming and directions services

I’m looking to force Google direction service to zoom to the final destination rather than show the entire route. Is this possible? If so how would you go about doing this? I would also like to remove the markers I set once the start and end locations have been set and the calculate route function is called is this possible? I don’t think any of the code will help it’s done in v3. I have been searching and found nothing related to the zoom issue. Can anyone please help…
Well this did help, now looking at it hough, i think maybe should have add my code. i'm going to try it in here first. I would like the "A" & "B" markers to stay i have built arrays for othere markers that i would like to suppress once the calculateroute function is handeld or have a button that turns them on and off that wont clear the map or add additional turn by turn directions.
First pass these options when intializing the directionsRenderer:
{suppressMarkers:true,preserveViewport:true}
...so you will not get markers and the map will not fit to the bounds of the route when rendering.
Then, after rendering the route( setDirections() ), call this:
directionsDisplay.setDirections(response);
//set the center of the map to the end of the route
map.setCenter(response.routes[0].legs[response.routes[0].legs.length-1].end_location);
//set the zoom to the desired value
(where directionsDisplay is the directionsRenderer-instance)

Android custom GPS map application

I want to build an app that uses GPS data and a building map I provide to show the user where in the building on the map they are. This will be done in a specific building that i already know gets GPS and cell service.
At first I thought the easiest way to do this was to see if I could use Google maps to plot the users location and then just "overlay" my custom building map on top of the Google map so that I wouldnt have to deal with any of the gps information or the complexities of the mapping I would just have to scale my "overlay" to fit properly on top of the Google map so that the user was shown in the correct room in a building. I'm wondering if anyone can provide me any information on how to do this or if there is an easier way to accomplish my map. Any information at all is helpful!
You want...
Google Map View
...and more specifically you will probably want to read the subsection appropriately titled: "Part 2: Adding Overlay Items"
EDIT: Whoops! Nevermind! I misread your question... that is only if you want to overlay an item on the map. Sorry...
There is no possibility to use closer zoom level than that you can see on standard GMap i.e. in browser. Other problem is that google uses GeoPoint class based on cardinal microdegrees to draw overlays, and it's accuracy is to low.
You can look on jGarminImg - it's java library - unfortunately written for using with swing, but it should be relatively easy to make it work with android. On the other hand - you have to make your own map.
You can use standard overlays, or you can make your map in kml format and use this example to display it.
You may be able to achieve this with a custom view that displays your building plan and knows the precise co-ordinates of each corner of the building.
When you receive your location updates you can add a marker to your custom view by translating the real world position into a position in the image using something along the lines of:
pseudocode:
markerX = realWorldX - mapStartX;
markerY = realWorldY - mapStartY;
if( isOnMap( markerX, markerY ) )
{
drawMarker( markerX, markerY );
}
Yes you can overlay bitmap images on top of the Google MapView.
All you have to do is subclass the Overlay class, override the draw method, and draw on the canvas. You have to provide a rectangle of GeoPoints (probably the top left and the bottom right corners) to anchor the building bitmap on top of the MapView. You use mapView.getProjection() to translate the latitude and longitude into xy coordinates on the canvas.
I assume drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) will be useful here. Bear in mind that src and paint can be null. If the GeoPoints you used are accurate, the bitmap will adjust automatically to pans and zooms, although it might get pixelated if the user zooms in too much.
edit: I am not so confident that Google Maps will have your building stays at the exact same GeoPoints in different zoom levels, so you might have to adjust those values for different zoom levels
If you need only the map of the building, it should not be too difficult to plot the location on an image without using Google Maps, provided that you can determine your location as coordinates inside the building.
You need to know two coordinates: north-west and south-east corners of the building map you are using. When you get GPS location updates, the correct location on the map image can be easily calculated based on these corner coordinates.
I would do it like this,
Place a marker on the google map to indicate the position of the building
Drilling down on the building would load your building map as a custom view. Plot the user location on the custom view
I think trying to overlay your building map on a google map while possible will be more complex to code than doing it via a custom view.
Also overlaying the lowest zoom level with your building map is not going to give you enough resolution unless you have a thumping big building. Whole blocks are pretty small
One issue you have probably already considered is the device will revert to cell tower and wifi for it's location when inside the building giving you a less accurate location fix.

Categories

Resources