How to set height and width for MapView?

Do you know about how to set coordinates (X, Y position), height and width for MapView ?


Asked by: Ned887 | Posted: 24-01-2022






Answer 1

You can control what the MapView is displaying by using the MapController. You get the MapController from the MapView using getController():

MapView map = (MapView) findViewById(R.id.MyMapId);
MapController controller = map.getController();

From there, you can check the documentation on how to control the center point or span. I've found zoomToSpan() to be particularly useful.

I'm not exactly sure what you mean by "height and width" of the MapView, but if you want to change the size of the MapView itself on the screen, you can just do it like you would do for any View (by setting the layoutHeight and layoutWidth, either in xml or dynamically in code).

Answered by: Lana589 | Posted: 25-02-2022



Similar questions

android - How to remove labels from a MapView?

I am trying to make a satellite view (via a MapView) without labels. How can I do this?


Android MapView is not working

Logcat output: [2010-01-09 15:47:19 - HelloMapView]------------------------------ [2010-01-09 15:47:19 - HelloMapView]Android Launch! [2010-01-09 15:47:19 - HelloMapView]adb is running normally. [2010-01-09 15:47:19 - HelloMapView]Performing org.example.hellomapview.HelloMapView activity launch [2010-01-09 15:47:19 - HelloMapView]Failed to find an AVD compatible with target 'Google APIs'. [2010-01-09 15:47:...


android - How to make 2 parted screen with MapView?

I am trying to make screen with Google Map. This screen has 2 parts. First part includes Button TextView and ListView and places on the top of Screen. Second part includes MapView (Google map) and places on the bottom of Screen. How to make it ? I've done it. But no luck. It throws this exception : 01-07 11:53:12.813: ERROR/AndroidRuntime(725): Uncaught handler: thread main exiting...


android - Manage cache of MapView

I've made an application based on the Google Maps API. The problem is that my application is made to be used in the wild, in places where there is no network. So I would like to manage the cache in order to ensure that specific tiles are saved and available during the trip (I'd like to redirect them in database but any method may do). For now, I didn't found any other method (not tested) than try to recode the Map...


google maps - Android MapView - tiles not loading with Debug API key

I am having some issues getting tiles to load into my MapView in android development. I have searched and looked at similar problems on here but with no luck so far. I have looked at the instructions here and have got hold of my debug API key. I have entered this into my MapView. I have...


How can I detect if an Android MapView has been panned or zoomed?

I'm creating an Android app that searches for items based on the visible area of the MapView. Is there a way to set up a listener on my MapView to detect when a map has been panned or zoomed?


google maps - how to get the long & lat value of four corners in the mapview in android?

i working on map view. i want to put overlay item on the map view. that overlay items are all depends on currently showing map view and zoom level. how to get current map view's longitude and latitude of that four corner and how to analyze how many overlay item inside it. also we have to check thee zoom level.Any Idea? how to do it?


android - Drop pin in MapView

I readed this: Drop Pin on Default Google Maps from My App in Android? and do all the same. But there is no pin droped on the map, after i call: startActivity(new Intent(Intent.ACTION_VIEW, uri)); The map centered on that uri-location, but no any pin dropped on the map. So, there is a question: How to drop p...


java - Double tap: zoom on Android MapView?

After a little bit of work my route application works fine. The only thing I just want to add is a double tap zoom in function, but I don't know how. Could you give me a hint?


Android MapView with High Res tiles?

I have created a simple map app that shows the local garage sales in my town. It was simple enough to create and I parse out the Google Maps (html) xml doc that the local paper uses on their google maps mashup on their website. I have noticed that the Map Tiles used in the MapView class are not as high-res as the tiles used in the real Android Google Maps app (I have a Droid). I have searched the docs and google, b...


android - digital compass problem

I am creating an augmented reality application and I noticed that the stored locations don't appear appear on the correct direction if I try to use the camera view (using layar or wikitude API). The problem is that the digital compass doesn't show north correctly when you try to look at the known objects through the camera view. If align the phone with the ground (look at my shoes) the locations appear at the screen accord...


android - How to remove labels from a MapView?

I am trying to make a satellite view (via a MapView) without labels. How can I do this?


android - Custom title with image

i'm creating custom title for activity by disabling standard one and managing everything myself. I wonder if it's possible to replace/theme standart title to my needs. I can customize size, background image, and text via themes by changing windowXYZStyle items. The only thing i couldn't find - how i can add image instead of text. I've tried requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) and ...


canvas - Android draw with blur

I need do draw on Android's Canvas using Blur effect, it is a very simple feature, I need to draw a circular area, which is blurred (the foreground) and the background transparent, I can do everything with manipulating the colour alpha to do it with custom transparency but I need it to be blurred instead of transparent.. any ideas?


layout - How to resize a android webview after adding data in it

In a layout (linear, vertical) hierarchy I've got several views and one of them is a WebView. They all have same parameters: android:layout_width="fill_parent" android:layout_height="wrap_content" For all views, the spacing between elements is correctly handled but for the Webview there is a lot of spaces after the displayed text inside. I set the (HTML) text of the webview in the ...


How to find easily the source of an android class

I know I can access android source code from https://android.googlesource.com, but it's hard to select the right git repo if I only know the package and the name of an android class. Isn't there a way to locate a file in https://android.googlesource.com?


camera - Android Intent Save Path

At the moment I am using two intents. One for voice-recording, another for the camera: Intent photoIntent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(photoIntent, ACTIVITY_TAKE_PHOTO); Intent voiceIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); startActivityForResult(voiceIntent, ACTIVITY_RECORD_SOUND); My aim is to put an Extra to each of t...


Android "hover" event in custom layout

I have a custom layout that I have written that basically just displays a bunch of ImageViews. I am handing onTouch events for all the ImageViews in my layout. However, if a user touches one imageView and then drags over another ImageView, I would like to be able to handle that as well. How would I go about capturing this behaviour?


android - What is the ideal place to cache images?

I am fetching a lot of thumbnails in my application from a remote server and lazy-loading these in a list view. The image fetches run in a background AsynTask and when completed the fetched images are stored in a HashMap using SoftReferences. This works just fine but when the images in the cache gets GC’d, the fetches have to be rerun. I could have stored them on the SD card so there would be no...


How to create a tree view in Android?

There are no controls in Android that provide Tree-like View. There is an ExpandableList View which I suspect could be used to creating one. Have you tried imlpementing such a control? How would one implement such a control in Android?






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top