android-mapview

Restoring MapView's state on rotate and on back

痴心易碎 提交于 2019-11-27 00:07:16
问题 Background I have a larger application in which I had/have several problems with new Google Maps API. I tried to describe it in a different question but since it seems too complex I decided to start a new project, as simple as possible and try to reproduce problems. So here it is. The situation I'm using Fragments and want to put MapView inside. I don't want to use MapFragment . The sample project I prepared may be not very beautiful but I tried to make it as simple as possible and it had to

How do you draw text with a border on a MapView in Android?

五迷三道 提交于 2019-11-26 23:56:41
I'm trying to draw some text onto an MapView on Android. The drawing of the text goes fine, but it's very hard to read the text because it's white with no black border (like the rest of the text that appears naturally on MapViews to denote cities, states, and countries). I can't seem to figure how to draw the text with a black border. Anyone know how to do this? This is the sort of code I'm using right now (this is just example code, found in one of my overlays): @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { Paint textPaint = new Paint(); textPaint.setARGB(255,

Mapview getLatitudeSpan and getLongitudeSpan not working

北慕城南 提交于 2019-11-26 23:23:31
问题 Sometimes when trying to get the Latitude span or Longitude span of a mapview with getLatitudeSpan() and getLongitudeSpan() I get 0 and 360*1E6 respectively. This doesn't happen always but it is a problem, has anybody got this problem? Any workarounds? I tried using getProjection() too but I get the same problem. Here is the piece of code: MapView mapView = (MapView) findViewById(R.id.mapview); int lat = mapView.getLatitudeSpan(); // sometimes returns 0 int long = mapView.getLongitudeSpan();

MapView rendering with tiles missing with an “x” in the center

牧云@^-^@ 提交于 2019-11-26 22:53:55
This is very, very strange. I've never seen anything like it. At the time I am took this screenshot, I'm not loading any overlays. First, I thought it was my internet connection where it couldn't download the tile information; but we have many users reporting the same issue who downloaded from the market. This just started happening like a week ago. Not sure why though. Anyone have a clue? Thanks! tdavisjr Ok. After starting from a clean project I found these two lines of code that was the culprit. mapView.setSatellite(true); mapView.setStreetView(true); They appeared back to back of each

Android Geocoder getFromLocationName always returns null

人盡茶涼 提交于 2019-11-26 22:42:01
I have been trying to geocode a string to get its coordinates but my program always crashes because when ever I try to use getFromLocationName() it returns null . I have been trying to fix this for hours but nothing is working. Here is my code public class MainActivity extends Activity { private GoogleMap mMap; List<Address> addresses; MarkerOptions miami; String myLocation = "Miami,Florida"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (mMap == null) { mMap = ((MapFragment) getFragmentManager()

Map View draw directions using google Directions API - decoding polylines

独自空忆成欢 提交于 2019-11-26 22:02:55
I'm trying to use the Google directions API to show directions on my mapview but I am having difficulties getting the data from the JSON response. I can get the "levels" and "points" strings but can't work out how to decode them to points on the map. Any help would be much appreciated. Kenny I have a class which can decode them for you, add the class below then call in your code like this: int[] decodedZoomLevels = PolylineDecoder.decodeZoomLevels(levels); GeoPoint[] gPts = PolylineDecoder.decodePoints(points, decodedZoomLevels.length); where points and levels are the data you've extracted

Android: How do I set the zoom level of map view to 1 km radius around my current location?

Deadly 提交于 2019-11-26 21:30:17
I want to set the map view zoomed to 1km radius but cant figure out how? The doc says that the zoom level 1 will map earths equator to 256 pixels. So how do I calculate which zoom level I need to set so that the map view shows area in 1KM radius? UPDATE: After reading a few blog posts I wrote the following code: private int calculateZoomLevel() { double equatorLength = 6378140; // in meters double widthInPixels = screenWidth; double metersPerPixel = equatorLength / 256; int zoomLevel = 1; while ((metersPerPixel * widthInPixels) > 2000) { metersPerPixel /= 2; ++zoomLevel; } Log.i("ADNAN", "zoom

Why do 9-patch graphics size correctly in the emulator but not on a phone?

一曲冷凌霜 提交于 2019-11-26 21:21:24
问题 I have a RelativeLayout that has a 9-patch background image. The image is a simple speech bubble with a perfectly centered "arrow" at the bottom middle. The RelativeLayout is inflated and placed on a MapView. Using the emulator, the speech bubble can be easily pointed to a location and will expand to its contents (text, an image, or both). When I run my app on a phone however, the 9-patch doesn't stretch properly. The "arrow" for the speech bubble will be offset to the left by a very

Android Rotating MapView

孤街醉人 提交于 2019-11-26 20:22:11
问题 I am creating an application which trakcs down users path on a mapview. What I want to achieve when user takes a left turn for instance map should rotate it self in such a way that the head of the mapview should always point to upward direction. I hope that makes sense. I came across Mr. Romain Guy's post an he says I have done this in the past and it requires to create a custom ViewGroup that rotates the Canvas in the dispatchDraw() method. You also need to increase the size of the MapView

How can I draw an Arrow showing the driving direction in MapView?

社会主义新天地 提交于 2019-11-26 19:38:31
问题 I use that Google Maps component MapView in an Android application. I can use the GPS location to show my location with a dot. But I would like to show an arrow instead, that points out the driving direction (bearing). I think that I can use the bearing value to get the angle of the arrow. How can I do that? 回答1: Assuming you've got the Location then obtain the bearing by doing: float myBearing = location.getBearing(); To implement the overlay you'll be using ItemizedOverlay and OverlayItem.