MapImageGenerator

Since: BlackBerry 10.0.0

#include <bb/cascades/maps/MapImageGenerator>

To link against this class, add the following line to your .pro file: LIBS += -lbbcascadesmaps

A generator which makes an asynchronous request for a map image.

To generate a map image, construct an instance of this class with a ViewProperties object with the map center coordinates and altitude, set the window size to a QRect with the width and height for the image, connect your slot to the finished() signal, and then call start().

The following example generates a 600px X 600px image of Waterloo, Ontario without a pin in the center:

ViewProperties prop;
prop.setAltitude( 3000.0 );
prop.setLatitude( 43.4706 );
prop.setLongitude( -80.5361 );
QRect size( 0, 0, 600, 600 );
prop.setWindow( size );
MapImageGenerator* generator = new MapImageGenerator( prop );
QObject::connect( generator,
    SIGNAL( finished( bb::cascades::maps::MapImageGenerator* ) ),
    this,
    SLOT( imageAvailable( bb::cascades::maps::MapImageGenerator* ) ) );
generator->start();
This example generates a 600px X 600px image of Waterloo, Ontario with a pin in the center:
ViewProperties prop;
prop.setAltitude( 3000.0 );
prop.setLatitude( 43.4706 );
prop.setLongitude( -80.5361 );
QRect size( 0, 0, 600, 600 );
prop.setWindow( size );
GeoList data;
GeoLocation* location = new GeoLocation( 43.4706, -80.5361, this );
location->setName( "Waterloo, Ontario" );
data.add( location );
MapImageGenerator* generator = new MapImageGenerator( prop, data );
QObject::connect( generator,
    SIGNAL( finished( bb::cascades::maps::MapImageGenerator* ) ),
    this,
    SLOT( imageAvailable( bb::cascades::maps::MapImageGenerator* ) ) );
generator->start();
The finished() signal will be emitted when the image is available and the ImageData can be obtained from it like so:
void MapImageGeneratorExamples::imageAvailable( bb::cascades::maps::MapImageGenerator* reply ) {
    bb::ImageData imgD = reply->imageData();
    if ( imgD.isValid() ) {
        Image img( imgD );
        mapImageView->setImage( img );
    } else {
        qDebug() << "Error loading image";
    }
    reply->deleteLater();
}


Overview

Public Functions Index

MapImageGenerator (const bb::cascades::maps::ViewProperties &viewProperties, QObject *parent=0)
MapImageGenerator (const bb::cascades::maps::ViewProperties &viewProperties, const bb::platform::geo::GeoList &data, QObject *parent=0)
virtual ~MapImageGenerator ()
bb::cascades::maps::MapImageGeneratorError::Typeerror () const
QStringgeneratorSourceName () const
bb::ImageDataimageData () const
voidsetGeneratorSourceName (const QString &src)
voidstart ()

Signals Index

voidfinished (bb::cascades::maps::MapImageGenerator *generator)

Public Functions

MapImageGenerator (

Constructor based on view.

This constructor generates a map image based on a view.

Parameters
viewProperties

The view to base the image upon.

parent

The parent object of this object.

Since:

BlackBerry 10.0.0

MapImageGenerator (

Constructor based on view and mappable data.

This constructor generates a map image based on a view and mappable data.

Currently the data in GeoList will not be included in the image. If the GeoList contains at least one item, the image will contain a pin in the center (if possible in the requested image dimensions).

Parameters
viewProperties

The view to base the image upon.

data

The data to include in the image.

parent

The parent object of this object.

Since:

BlackBerry 10.0.0

virtual~MapImageGenerator ()

Destructor.

bb::cascades::maps::MapImageGeneratorError::Type error ()

Retrieves any error that might have occurred while trying to get a static map by calling start().

See bb::cascades::maps::MapImageGeneratorError for a list of error codes.

Return:

The error code.

Since:

BlackBerry 10.2.0

QString generatorSourceName ()

Retrieves the name of the image generator source.

Prior to calling start(), this method returns the source name, as set by setGeneratorSourceName(const QString& src). After start(), this method returns the source name actually used. If a file name was specified but not found, this method returns QString::null.

Return:

The generator source name.

Since:

BlackBerry 10.2.0

bb::ImageData imageData ()

Gets the image data.

If bb::ImageData::isValid() returns false, there was an error generating the image.

Return:

The resulting image.

Since:

BlackBerry 10.0.0

void setGeneratorSourceName (

Sets the source of the underlying generator used to produce map images.

The generator source name must be set before the start() method is called. Changing the generator source name of a request that is in progress will have no effect.

The possible values for the source generator name are:
  • "default", an empty string or QString::null. If one of these values is supplied, then the default search rules are used.

  • "built-in". If this value is supplied, the built-in generator is used.

  • The name of the shared library containing the generator plug-in to be used. If necessary, the appropriate extension for shared libraries will be added. If the library cannot be found then start() will not generate a map image.

Note:

Setting the source does not affect the existing cached images on device.

Parameters
src

The name of the source generator.

Since:

BlackBerry 10.2.0

void start ()

Starts the image generation process.

Since:

BlackBerry 10.0.0

Signals

void finished (

Emitted when the image is ready.

Parameters
generator

The map image generator used to make the request for a static map image.

Since:

BlackBerry 10.0.0

Last modified: 2014-09-30



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus