void ApplicationUI::addMarker(QObject* mapObject, double lat, double lon, QString nombre){ MapView* mapview = qobject_cast<MapView*>(mapObject); GeoLocation* loc = new GeoLocation(lat, lon, mapview); loc->setName(nombre); mapview->mapData()->clear(); mapview->mapData()->add(loc); }
//! [0] //! [1] void MapViewDemo::addPinAtCurrentMapCenter() { if (mapView) { GeoLocation* newDrop = new GeoLocation(); newDrop->setLatitude(mapView->latitude()); newDrop->setLongitude(mapView->longitude()); QString desc = QString("Coordinates: %1, %2").arg(mapView->latitude(), 0, 'f', 3).arg(mapView->longitude(), 0, 'f', 3); newDrop->setName("Dropped Pin"); newDrop->setDescription(desc); // use the marker in the assets, as opposed to the default marker Marker flag; flag.setIconUri(UIToolkitSupport::absolutePathFromUrl( QUrl("asset:///images/on_map_pin.png"))); flag.setIconSize(QSize(60, 60)); flag.setLocationCoordinate(QPoint(20, 59)); flag.setCaptionTailCoordinate(QPoint(20, 1)); newDrop->setMarker(flag); mapView->mapData()->add(newDrop); } }