开发者

Zoom controls not showing when using a MapView with fill_parent

开发者 https://www.devze.com 2023-01-03 02:05 出处:网络
Hey everyone I am working on an applications and I am using the built in zoom controls. When using a specific size I can see the zoom controls. When using fill_parent the zoom controls are not visible

Hey everyone I am working on an applications and I am using the built in zoom controls. When using a specific size I can see the zoom controls. When using fill_parent the zoom controls are not visible. How it is setup is a mapview inside of a frame layout(also using fill parent for the height and width but with an offset down the screen. The only thing I can think of is the fill pare开发者_开发知识库nt issue is with the framelayout and the zoom controls are off the screen. Sorry if this is confusing, I confused myself writing it. Thanks in advance


Had a similar issue while trying to get the zoom controls working on my app.

Discovered that the layout for the MapView MUST be set to "clickable" in order for the zoom controls to show up and be functional. They don't even show if the map's not clickable

Here's a simple layout from Android SDK site that shows the tag in the layout.

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="Your Maps API Key" />

After putting that tag into the layout, everything worked correctly.


You can use ZoomControls like this.

ZoomControls mapZoomControl = (ZoomControls) findViewById(R.id.zcMapZoomControl);
mapZoomControl.setOnZoomInClickListener(new OnClickListener() {
        public void onClick(View v) {
            myMap.getController().zoomIn();
        }
});
    mapZoomControl.setOnZoomOutClickListener(new OnClickListener() {
        public void onClick(View v) {
            myMap.getController().zoomOut();
        }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号