Вопрос

I have portrait oriented android application. There is static map with width="match_parent". For devices with screen width bigger than 640 pixels - map is not big enough. Is it good idea to enlarge map?

Это было полезно?

Решение

I had same problem (map was not big enough), and this is how I solved it :

// Used WindowManager to get screen size, because this was a customview.
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

String lat = YOUR_LAT;
String lng = YOUR_LNG;

String mapEndpoint = "http://maps.google.com/maps/api/staticmap?center=" + lat + "," + lng + "&zoom=17&size=" + width/2 + "x" + height/2 + "&scale=2";

Basically I used scale and divided width and height by the same scale value. You'll get full screen of map with above code.

I still feel it was pretty hacky, so if there's anyone who knows the correct way, please give me a comment!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top