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)
Related
I am using Google map v2,everything works fine from viewing the map to applying polyline between markers.However there is one thing that I need to accomplish, it is to put arrow header inside the commonly used map marker.
The arrow must rotate or point to the direction of the next location and so on. here's the image looks like
map_marker
I have tried using only the arrow alone and it works fine with the use of .rotation(bearing) but my boss wants it inside the commonly used marker and only the arrow will move.They have a working sample but it works only in the browser using javascript.I haven't found samples or at least documentation about it on the internet only this similar question
How to display direction arrows in the map marker for google maps v2 android but unfortunately no one answered. I have also tried
.icon(BitmapDescriptorFactory.fromBitmap(getMarkerBitmapFromView(R.drawable.arrow_header)))
but the both the marker and arrow moves
I have done everything to accomplish this task and this would be my last resort just to inform my boss that just in case there is no way that it'll work on android. Thank you..
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.
Ok, Hello everyone (sorry for my English). I have a task to make some good location service. I use google and stackoverflow , find a lot of tutorials, but i want to ask am i right? I have destination point and my current geo position. I draw route like this tutorial http://iamvijayakumar.blogspot.com/2013/04/android-draw-route-between-two-geo.html, and now i want to react if my current position changed, so i implement OnMyLoactionChangeListner, and now the question: if my position change i have to get new rout from url and redraw my polyline, or i can just make a marker and mark my new position above the old route polyline? what decision is right? Thanks for all
I think that best would be to check if your current position is on the old route. If so, you could just shorten the first polyline. But if the position is outside of the route, you have to recalculate it.
I'm implementing a feature in my app that allows user to manually locate themselves on a map. So I use a pin to represent their location and let user drag it to the place they currently are. The simple solution is to use setDraggable(true) on the marker, but this requires users to hold the marker for 3 or 5 seconds until it is draggable. I think this is quite confusing for many user to use the feature. So, what I want is to make the dragging more responsive by letting users drag them immediately without having to hold it for a while - like how Foursquare does!
What should I do to implement my own dragging feature? If you have any suggestions, please help me and thanks.
Check out the Hailo application. They have a neat workaround for this. It only works when you have one marker to drag.
The trick is to pan the map, instead of moving the marker. They just keep the marker in a view on top of the MapFragment (it's not actually a Marker on the map).
You can then use the map's cameraPosition.target as the location of your marker.
I'd like to dynamically update the map/ load new map overlays every time my user moves it a certain amount of distance. How do I go about doing this? Is there a listener for every time the user moves the map? Most likely I'd just measure the distance between the center points.
Thanks!
Try this to detect the map movements:
http://pa.rezendi.com/2010/03/responding-to-zooms-and-pans-in.html
On start and after the map has been moved, you should save the current map center. As the article suggests, track ACTION_UP to determine when the user has finished a map movement. Then, compare the new map center with the old map center. To get the map centers use MapView's getMapCenter():
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html#getMapCenter()
EDIT: I have done some additional work on this, and have a complete application with code for your enjoyment. This blog post explains a timer solution to this and contains a link to Github source:
http://bricolsoftconsulting.com/extending-mapview-to-add-a-change-event/
The map interface unfortunately does not include any listeners to monitor map actions (zoom/pan). You'll need to set up a timer of some sort that checks the center/zoom levesl to figure out if things have changed and update accordingly.
You could do this by overriding the onTouch(...) method in your Activity (so that every time the user pans the map, you could recalculate the map boundaries). You would need to know the map's zoom level and boundaries, etc, in order to load these overlays based on map distances.