简体   繁体   中英

How to load an ImageView and focus a certain part of the picture ( by some x and y coordinates?)

I am working on an application that gives details on locations on a map. I would like to give the user the ability to click the location name (on a details page) and then have the app load a large map and have the focus set to the location on the map (preferably zoomed to the locations particular area).

I have searched high and low and have not found a way to load an ImageView and have a specific x,y coordinate focused.

Any help would be great Thanks

Let xMap and yMap be the coordinates of the point you want to focus at. width and height are respectively of the screen.

Now you would want to make this point coincide with the center of the screen.

What you could do is crop off portions of the large jpg to obtain a smaller bitmap of dimensions matching the screen dimensions, with the focus point at the center.

Code for cropping the bitmap:

Bitmap focusPoint = Bitmap.createBitmap(largeMapBitmap, xMap-width/2,yMap-height/2,width, height);

And then you can set this bitmap to your imageview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM