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
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
Accepted Solution

How to get Static Image from Location (Lon & Lat)

Hi, I have location (Lon & Lat),

How to get Static Image from that data?

 

 

Thanks

 

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

Re: How to get Static Image from Location (Lon & Lat)

Do you need more of a sophisticated answer than just use MapView?

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__maps__mapview.html

 

Hard to tell from your question.


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: How to get Static Image from Location (Lon & Lat)

If you are asking how to save an image from a MapView then you can use the generateStaticMapImage() function...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__maps__mapview.html#function-...


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
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: How to get Static Image from Location (Lon & Lat)

[ Edited ]

Maybe like on BlackBerry 10 Foursquare app, on detail POI they have an map image

 

IMG_00000394.png

 

 

I want something similar to this, when the image click will invoke map

 

Oh I will try your suggestion using

 generateStaticMapImage() function

 

Thanks

Developer
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: How to get Static Image from Location (Lon & Lat)

[ Edited ]

Hi, I'm already try  generateStaticMapImage()  function

 

But I have dificulty to show it on ImageView

 

How to show the result image?

 

 

[

Note:

What I mean is something like  on static google map

https://developers.google.com/maps/documentation/staticmaps/#quick_example

]

 

Thanks

Developer
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: How to get Static Image from Location (Lon & Lat)

Hi I'm still facing this problem

 

I want to use static image map

Maybe like on google static image :

https://developers.google.com/maps/documentation/staticmaps/#quick_example

But use this static image from google has limitation count per day.

 

How to implement this in cascades?

 

I'm trying with generateStaticMapImage()  function from mapView

But has dificulty to show it to imageView

(maybe I'm wrong when use the bb::imagedata from generateStaticMapImage())

 

Is there any suggestion to solve this?

 

 

Thanks

Regular Contributor
coolneo
Posts: 56
Registered: ‎06-25-2012
My Device: non-blackberry user

Re: How to get Static Image from Location (Lon & Lat)

i think you should tell us about the problem of using generateStaticImage method, it returns an ImageData, i hope you are not directly using that !!

Developer
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: How to get Static Image from Location (Lon & Lat)

I'm trying like this:

on .qml

attachedObjects: [
   StaticMapImage {
      id: mapImage
   }
]

MapView {
   id: mapViewId
   latitude: detailData.location.lat
   longitude: detailData.location.lon
   altitude: 3000
   preferredWidth: screenWidth
   preferredHeight: 300
   visible: false
}         

ImageView {
   image: mapImage.setImageData(mapViewId.generateStaticMapImage())
   preferredWidth: screenWidth
   preferredHeight: 300
} 

 

on StaticMapImage:

QVariant StaticMapImage::setImageData(bb::ImageData aImageData)
     {
     bb::cascades::Image image = bb::cascades::Image(aImageData);
     return QVariant::fromValue(image);
     }

 

But I think I'm wrong on implement this

 

Any suggestion?

 

 

Thanks

Developer
Kaz32
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: How to get Static Image from Location (Lon & Lat)

[ Edited ]

Read from JAM373 blackberry jam europe

and

http://supportforums.blackberry.com/t5/Native-Development/crush-in-bb-cascades-ImageView-setImage/m-...

 

Found solution using MapImageGenerator

 

I'm implement like this

on .qml:

function getImage() {
   mapImage.getImageMap(lat, lon, screenWidth);
}

attachedObjects: [
   StaticMapImage {
     id: mapImage
     onGetProperties: {
       staticMapImage.image = aPropertyMap.img;
     }
  }
]

ImageView {
   id: staticMapImage
   preferredWidth: screenWidth
   preferredHeight: 300
}

 

 

on StaticMapImage.cpp:

StaticMapImage::StaticMapImage(QObject *parent):
	QObject(parent)
	{

	}

void StaticMapImage::getImageMap(const double &aLatitude, const double &aLongitude, int width)
	{
	ViewProperties mapProperties;
	mapProperties.setLatitude(aLatitude);
	mapProperties.setLongitude(aLongitude);
	QRect windowRect(0,0, width, 300);
	mapProperties.setWindow(windowRect);
//	mapProperties.setAltitude(500);

	iMapImageGenerator = new MapImageGenerator(mapProperties);
    bool result = connect(iMapImageGenerator,
            SIGNAL(finished(bb::cascades::maps::MapImageGenerator *)),
            this, SLOT(imageFinished(bb::cascades::maps::MapImageGenerator *)));
    Q_ASSERT(result);
    Q_UNUSED(result);

    iMapImageGenerator->start();
	}

void StaticMapImage::imageFinished(bb::cascades::maps::MapImageGenerator *aMapImageGenerator)
	{
	bb::cascades::Image img(aMapImageGenerator->imageData());

	QDeclarativePropertyMap* propertyMap = new QDeclarativePropertyMap;
	propertyMap->insert("img",  QVariant(QVariant::fromValue(img)));
	setProperties(propertyMap);

//	delete iMapImageGenerator;
	}

QDeclarativePropertyMap *StaticMapImage::properties()
	{
	return iPropertyMap;
	}

void StaticMapImage::setProperties(QDeclarativePropertyMap *aPropertyMap)
	{
	iPropertyMap = aPropertyMap;
	emit getProperties(iPropertyMap);
	}

 

 

on StaticMapImage.hpp:

class StaticMapImage: public QObject
{
    Q_OBJECT
    Q_PROPERTY(QDeclarativePropertyMap *properties READ properties WRITE setProperties NOTIFY getProperties)
public:
    StaticMapImage(QObject *parent = 0);
    Q_INVOKABLE void getImageMap(const double &aLatitude, const double &aLongitude, int width);

private slots:
    void imageFinished(bb::cascades::maps::MapImageGenerator *aMapImageGenerator);

public slots:
	QDeclarativePropertyMap *properties();
	void setProperties(QDeclarativePropertyMap *aPropertyMap);

signals:
	void getProperties(QObject *aPropertyMap);

private:
    MapImageGenerator *iMapImageGenerator;
    QDeclarativePropertyMap *iPropertyMap;
};

 

 

Thanks