Question

I'm devolopping a Blackberry 10 mobile application using the BB Native SDK.

I'm adding a map part into my app. and I'm adding markers dynamically using C++.

All I want is when the bubble apear when clicking into a marker, I want to handle the action button part in order to display a new page containing all the relative informations (altitude, longitude, address, etc.) of the clicked marker.

can anyone help me on this ?

Was it helpful?

Solution

You don't say if you are using a MapView object to display your map. If you are then there are two signals that are emitted in association with gestures on the marker caption bubble:

  1. captionButtonClicked()
  2. captionLabelTapped()

You can use one of those two signals to post a sheet with the information. I use the second one because the normal behavior for the button click is to get a navigation route to the location of the marker. If you aren't providing that service, they you could use that signal for your purpose.

The ID of the focused marker (the marker to which the caption belongs) will be contained in the MapView property focusId. With this ID you can get the marker from the MapData object. I prefer to provide the markers with an ID that allows direct access to the data store that the MapData was drawn from, the primary key for the record in the data base, etc.

In one of my applications I have the captionLabelTapped() signal handled in QML like this:

        onCaptionLabelTapped: {
            console.log("Waypoint ID tapped " + focusedId);
            app.invokeWaypointPage(focusedId);
        }

And the invokeWaypointPage method invokes a card from another application:

void ApplicationUI::invokeWaypointPage(QString ident) {
    InvokeManager* invokeManager = new InvokeManager();
    InvokeRequest cardRequest;
    //cardRequest.setTarget("ca.sarmobile.OurAirportsDb.invoke.waypointPage");
    cardRequest.setAction("bb.action.VIEW");
    cardRequest.setMimeType("x-aviation/wp-ident");
    cardRequest.setData(ident.toAscii());
    InvokeTargetReply* reply = invokeManager->invoke(cardRequest);
    reply->setParent(this);
    reply->deleteLater();
}

In this case the marker ID is the item identifier (and primary key) in the database. If you are using a smaller data set you could put the information in a QMap or use an XmlDataModel.

To start with though you can get the latitude, longitude and some other data in C++:

double lat = qobject_cast<GeoLocation*>(pMapView->mapData()->geographic(focusId))->latitude();
double lan = qobject_cast<GeoLocation*>(pMapView->mapData()->geographic(focusId))->longitude();

Assuming, of course that the marker is a GeoLocation, not a Line or Polygon.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top