Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
bmorr
Posts: 331
Registered: ‎04-13-2013
My Device: Z10
Accepted Solution

Part of Mapview frame see through

[ Edited ]

I have an issue where my mapview on my navpane shows part of the map underneath, but ONLY if I do a swipe up gesture then go back into the app.  It shows this:

 

IMG_00000083.png

 

I'm using a Tabbed pane and currently I have this mapview in my first tab page:

 

Tabbedpane{

Tab {

MapView {
            touchPropagationMode: TouchPropagationMode.None
            id: mapview
            objectName: "mapViewObj"
            altitude: 3000
            preferredWidth: 768
            preferredHeight: 1280
            
            onLatitudeChanged: {
                lat.setText(qsTr("%1").arg(newLat));
            }
            onLongitudeChanged: {
                lon.setText(qsTr("%1").arg(newLon));
            }
            
            attachedObjects: [
                Invocation {
                    id: invokeSettings
                    query {
                        invokeTargetId: "sys.settings"
                        invokeActionId: "bb.action.OPEN"
                    }
                }
            ]
        }
]

Tab {

Naviagationpane{

Listview{

}

}
} }

 Under the second tab I have a navigation pane along with a listview that takes users to a details page when they click on a listitem:

Page {
id: listItemPage
ScrollView { scrollViewProperties.scrollMode: ScrollMode.Vertical Container { layout: StackLayout { } //! [0] Container { id: root layout: DockLayout { } MapView { horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Center touchPropagationMode: TouchPropagationMode.None id: mapview altitude: 3000 latitude: listItemLat.text longitude: listItemLon.text preferredWidth: 768 preferredHeight: 768 } } } } }

 If i make my underlying map visible=false I don't get this issue.  Is it possible to destro() Tab1 when I go to tab2 then create Tab1 when I click back on tab1?

BlackBerry Development Advisor
shaque
Posts: 237
Registered: ‎07-14-2008
My Device: Not Specified

Re: Part of Mapview frame see through

Hi,

As per your comment below

 

"If i make my underlying map visible=false I don't get this issue.  Is it possible to destro() Tab1 when I go to tab2 then create Tab1 when I click back on tab1?"

 

Can you simply set the visibility of mapview in tab1 to false when you go to tab2 and set it back to true when you get back to tab1?

 

Although not requried, it is recommended that you have one mapview instance at a time ..only creating and destroying them as you need.

 

Shadid

Developer
bmorr
Posts: 331
Registered: ‎04-13-2013
My Device: Z10

Re: Part of Mapview frame see through

How would I go about creating and destroying my mapview?  I simply want to destroy it when I leave Tab1 and create it when i go back to Tab1.

 

below is the mapview object cpp code:

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("_app", this);

    AbstractPane *root = qml->createRootObject<AbstractPane>();

    QObject* mapViewAsQObject = root->findChild<QObject*>(QString("mapViewObj"));
        if (mapViewAsQObject) {
            mapView = qobject_cast<bb::cascades::maps::MapView*>(mapViewAsQObject);
            mapView->setCaptionGoButtonVisible(true);
            if (mapView) {
                // creating a data provider just for the device location object. that way, when the clear function is call, this object is not removed.
                DataProvider* deviceLocDataProv = new DataProvider("device-location-data-provider");
                mapView->mapData()->addProvider(deviceLocDataProv);

                // create a geolocation just for the device's location
                deviceLocation = new GeoLocation("device-location-id");

                // for that location, replace the standard default pin with the provided bulls eye asset
                Marker bullseye = Marker(UIToolkitSupport::absolutePathFromUrl(
                                    QUrl("asset:///images/me.png")), QSize(60, 60),
                                    QPoint(29, 29), QPoint(29, 1));
                deviceLocation->setMarker(bullseye);

                deviceLocDataProv->add(deviceLocation);
            }
        }

 

 

Here's my QML with the main mapview I want to destroy and create:

 

Container{
        
            }
        ]
        id: mapViewContainer
        layout: DockLayout {
        }
        //! [1]
        MapView {
            touchPropagationMode: TouchPropagationMode.None
            id: mapview
            objectName: "mapViewObj"
            altitude: 3000
            preferredWidth: 768
            preferredHeight: 1280
            
            onLatitudeChanged: {
                lat.setText(qsTr("%1").arg(newLat));
            }
            onLongitudeChanged: {
                lon.setText(qsTr("%1").arg(newLon));
            }
        }
        //! [3]
        Container {
            leftPadding: 20
            rightPadding: 20
            bottomPadding: 20
            topPadding: 20
            horizontalAlignment: HorizontalAlignment.Right
            verticalAlignment: VerticalAlignment.Bottom
            overlapTouchPolicy: OverlapTouchPolicy.Allow
            
            ImageView {
                id: compassImage
                imageSource: "asset:///images/compass.png"
                horizontalAlignment: HorizontalAlignment.Center
                attachedObjects: [
                    ImplicitAnimationController {
                        // Disable animations to avoid jumps between 0 and 360 degree
                        enabled: false
                    }
                ]
            }
            Label {
                text: qsTr("Location") + Retranslate.onLanguageChanged
                textStyle.color: Color.Black
                horizontalAlignment: HorizontalAlignment.Center
            }
            ToggleButton {
                id: sensorToggle
                horizontalAlignment: HorizontalAlignment.Center
                checked: true
                onCheckedChanged: {
                    if (checked) {
                        mapview.setFollowedId("device-location-id");
                    } else {
                        mapview.setFollowedId("");
                    }
                }
                onCreationCompleted: {
                    mapview.setFollowedId("device-location-id");
                }
            }
        }
        //! [3]
    }

 

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Part of Mapview frame see through

If it's defined within C++ then you can set it's parent as the page and it will be destroyed when the page is.

If it's defined in QML then the parent is already correctly set.

 

As you pop a page make sure you destroy that page...

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Part of Mapview frame see through

NavigationPane {
    id: navigationPane

    [ ... ]

    onPopTransitionEnded: {
        page.destroy();		// Destroy the Page
    }

}

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
bmorr
Posts: 331
Registered: ‎04-13-2013
My Device: Z10

Re: Part of Mapview frame see through

I know how to destroy() but how do I create it again after it's been destroyed?

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Part of Mapview frame see through

[ Edited ]

Each time that page is pushed it will create the MapView object again.

 

If you destroy every page that gets popped then the objects within that page only live for the length of time that the page does.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
bmorr
Posts: 331
Registered: ‎04-13-2013
My Device: Z10

Re: Part of Mapview frame see through

thing is my app is a tabbed pain and the mapview is on the opening tab like so:

 

TabbedPane {

Tab1
{
Mapview
}

Tab2
{
List
}
}

 Would adding a NavigationPane under the Tab1 resolve this, and load the mapview when I click on Tab1?

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Part of Mapview frame see through

Are you doing different things with MapView or do you just want to show the same map on different pages.

 

If it's the first option then you should destroy the MapView object each time and create a new one for each page.

If it's the second object then create a global MapView and pass a pointer to it to each page.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Part of Mapview frame see through

You can do the same thing with a TabbedPane just hook in to the activePaneTransitionEnded signal.

 

If your minimum OS is 10.2 the it's better to use delegates.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.