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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Contributor
Posts: 7
Registered: ‎02-11-2013
My Device: Z10
My Carrier: KPN

Re: Is it possible draw overlays on a map?

Set up a map and a image in QML

Container {

                id: mapViewContainer

                layout: DockLayout {}

                background: Color.Green

                horizontalAlignment: HorizontalAlignment.Center

                verticalAlignment: VerticalAlignment.Center   

                

                MapView {

                    id: mapView     

                    objectName: "mapView"       

                    altitude: 1000 //settings.altitude

                    latitude: 52.2

                    longitude: 4.4

                    enabled: false

                    altitudeMode: AltitudeMode.ClampToGround

                    horizontalAlignment: HorizontalAlignment.Fill

                }

                ImageView {

                    id: anchorCircleImage

                    image: controller.circleImage

                    preferredHeight: 768/2

                    preferredWidth: 768/2

                    verticalAlignment: VerticalAlignment.Center

                    horizontalAlignment: HorizontalAlignment.Center

                }

 

Then fetch the image in C++ and adapt if needed

 

void AnchorWatch::updateImage()

{

QSize size(720, 1200);

QImage finalImage = Draw::drawCircle(size);

m_circleImage = Draw::fromQImage(finalImage);

 

emit circleImageChanged();

}

 

Hope it helps

 

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

Re: Is it possible draw overlays on a map?

Welcome back :-)

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

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 11
Registered: ‎10-12-2013
My Device: Z10

Re: Is it possible draw overlays on a map?

Thx! This brings me to an good idea how to do it but may I ask you where the following methods come from?

 

QImage finalImage = Draw::drawCircle(size);

m_circleImage = Draw::fromQImage(finalImage);

 


I guess that's where the "magic" is happening :-)

New Developer
Posts: 11
Registered: ‎10-12-2013
My Device: Z10

Re: Is it possible draw overlays on a map?

I guess from which example this code comes from ;-)

But I am still a bit struggeling :-D

Retired
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is it possible draw overlays on a map?

Don't mean to distract from the conversation but drawing your own circles or images on top of the map will have a slight delay that some might find annoying although this may be your only option.

 

Alternatively, you could use

bb:Smiley Tonguelatform::geo::Geographic
bb:Smiley Tonguelatform::geo::GeoShape
bb:Smiley Tonguelatform::geo::GeoPolygon
bb:Smiley Tonguelatform::geo::GeoPolyline

 

They wont give you a perfect circle but you could get close to one with a polygon if that helps. This is available since 10.2.


To draw a circle by using a polygon:

    GeoPolygon* result = new GeoPolygon;

    double lat, lon, radius; // set somewhere else

    Polyline line;
    // convert radius meters to latitude width
    double r = radius / 111412.84; // this is the number of meters per degree
    const int numOfSeg = 18;
    for ( int i = 0; i < numOfSeg; i++ ) {
        double theta = 2.0f * 3.1415926f * float( i ) / float( numOfSeg );
        double x = r * cosf( theta );
        double y = r * sinf( theta );
        line.append( Coordinate( y + lat, x + lon ) );
    }

    result->setOuterBoundary( line );

 

Highlighted
New Developer
Posts: 11
Registered: ‎10-12-2013
My Device: Z10

Re: Is it possible draw overlays on a map?

Thank you! This looks much better than what I had before.

I tried to play a bit with your code to optimize the "look & feel" but

my "circle" is always looking like an "egg".

 

Maybe you have an idea what I could do to let it look better.

My goal was/is to create a radar around the device position and

in this radar you can see the points of interest. The radius is always

updated when the slider in my app is set to a new search radius.

So replaced your radius with mine to make it moke flexible.

New Contributor
Posts: 7
Registered: ‎02-11-2013
My Device: Z10
My Carrier: KPN

Re: Is it possible draw overlays on a map?

Yes, you should use the Geo stuff, my code dates from 10.0 and falls back to the native Qt classes.