1

I have an Android app that uses a screen overlay to place buttons on top of Pokemon Go. The buttons call methods to draw polygons on the map in the background. I have the buttons working how I want them to, but what I really want is to create an overlay onto of Pokemon go that shows my map so the user doesn't have to switch back and forth. (I just uploaded a version with the working buttons if you want to see that: https://play.google.com/store/apps/details?id=kavorka.venn_tracker).

I cant seem to get a copy of my SupportMapFragment into a view in my overlay, does anyone know a way to get this to work?

I am using a MapWrapperLayout so I can have a custom map info window with buttons (I don't know if there is a better way).

Here is the code that is called when I start the overlay:

Binder binder = new Binder();
WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
        PixelFormat.TRANSLUCENT);
params.gravity = Gravity.LEFT | Gravity.TOP;
params.width = 150;//mButtonCircleGreen.getLayoutParams().width;
params.height = 150;//mButtonCircleGreen.getLayoutParams().height;
params.token =  binder;

WindowManager.LayoutParams greenParams = new WindowManager.LayoutParams();
WindowManager.LayoutParams redParams = new WindowManager.LayoutParams();
greenParams.copyFrom(params);
redParams.copyFrom(params);

greenParams.x = mSharedPref.getInt("overlay_green_x", (int) mButtonCircleGreen.getX());
greenParams.y = mSharedPref.getInt("overlay_green_y", (int) mButtonCircleGreen.getY());
redParams.x = mSharedPref.getInt("overlay_red_x", (int) mButtonCircleRed.getX());
redParams.y = mSharedPref.getInt("overlay_red_y", (int) mButtonCircleRed.getY());

topLeftView = new View(this);
WindowManager.LayoutParams topLeftParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
topLeftParams.gravity = Gravity.LEFT | Gravity.TOP;
topLeftParams.x = 0;
topLeftParams.y = 0;
topLeftParams.width = 0;
topLeftParams.height = 0;
topLeftParams.token = binder;

WindowManager.LayoutParams mapParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
mapParams.gravity = Gravity.CENTER | Gravity.CENTER;
mapParams.x = 0;
mapParams.y = 0;
mapParams.width = 1000;
mapParams.height = 1000;
mapParams.token = binder;

wm.addView(topLeftView, topLeftParams);
wm.addView(mMapView, mapParams);
wm.addView(mOverlayedButtonGreen, greenParams);
wm.addView(mOverlayedButtonRed, redParams);

Here is where I get my map:

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this);

mMapView = new MapView(this);
mMapView.getMapAsync(this);

// Window manager for overlay
wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

Any ideas would be greatly appreciated :)

0 Answers0