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.
Related
I want to code a map application in Android(MinSDK=2.1).
But this map will not use any online features.It will be completely offline.
Also this map shows a high definition image which is drawn by me.I must specify points (like buildings,parkings,cafes...etc) and place little Imageviews on these points.
When needed , screen must move any requested point.
So Is there any sdk,library...etc to do this you know ? Or Should I implement myself.Lead the way pls.Thanks for any help...
Does anyone know how to:
1) make the Google map not zoom-able? make it so it is at a fixed zoom size and the user cannot change it?
2) have the map API load a picture of my choosing and overlay the little blue dot of the user's current location over it?
Here is what I want to do, I'm want to have a custom picture of the world (that i have created in Photoshop or w/e, it will be .jpeg, .png, or whatever file format will work) the picture of the world will be 'artsy' and I just want the Google maps to overlay the little blue dot of where you are in the world. For example, if you are in New York, NY, you will see the picture of the world with the blue dot over what on the picture is New York.
Any help will be greatly appreciated, Thanks
You should be able to control the map as follows:
map = (MapView) findViewById(R.id.mapview);
map.setBuiltInZoomControls(false);
As for overlaying an image, you'll need to create an image layout file (in XML) and then inflate that over the top of the map. This tutorial shows you the basics of inflating a layout and adding it to an existing view:
http://www.mysamplecode.com/2011/10/android-dynamic-layout-using-xml-add.html
To position the inflated layout (your image), you will need to use LayoutParams (http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html) to set the position of the new view on to the map.
Hope that helps.
Regarding you second question: it sounds like you actually want to replace the Google Maps tiles by images you've created yourself. As far as I know, that's not possible with the Maps API. You can potentially hack something together by adding your own creation as overlay to the map, but that may not give your the results you're looking for, especially if you want the user to still be able to pan/drag the map around.
In stead, you might want to take a look at the osmdroid (Open Street Maps for Android) project. They do support loading in your own tiles via the ModularTileProviderArchitecture. It'll probably give you more freedom and flexibility, but might be overkill for what you're after.
I know that OSM is hip and cool, but the OP asked about Google maps — and the question is readily answered in the Google Maps API documentation (https://developers.google.com/maps/documentation/javascript/).
The Google Maps API has supported custom maps for years. I think you can edit their first "ImageMapType" (https://developers.google.com/maps/documentation/javascript/maptypes#CustomMapTypes) example to solve your problem.
In your case, you would set the "maxZoom" and "minZoom" fields to whatever zoom you want to create artwork for. Use the "mapOptions" dictionary to take away the zoom control. You'll need to cut your artwork into tiles, and replace their "getTileUrl" function with one that returns your tiled image.
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)
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.
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.