[SailfishDevel] Generating MapQuickItems from model
Antoine Reversat
a.reversat at gmail.com
Thu Nov 28 09:03:12 UTC 2013
Well I was actually able to do what I want with MapItemView.
On Thu, Nov 28, 2013 at 3:52 AM, Antoine Reversat <a.reversat at gmail.com>wrote:
> Hi guys (and gals),
>
> I'm trying to populate a map with marker based on a model.
>
> I wanted to do this
>
> Map {
> id: stationsMap
> anchors.fill: parent
> plugin: nokia
> center: currentLocation.coordinate
> zoomLevel: stationsMap.maximumZoomLevel - 7
> gesture.enabled: true
>
> Repeater {
> model: myModel
> delegate: Marker {
> coordinate: QtPositioning.coordinate(latitude, longitude)
> }
> }
> }
>
> Each entry in my model contains a latitude and longitude property
>
> Here is Marker.qml
>
> import QtQuick 2.0
> import QtLocation 5.0
>
> MapQuickItem {
> property string type: "station"
>
> sourceItem: Image {
> id: marker
> source: type == "station" ? "../images/bikster-marker.png" :
> "../images/you-marker.png"
> }
> anchorPoint.x: marker.width/2
> anchorPoint.y: marker.height
> }
>
> Can somebody tell me what I'm doing wrong or the right way to dynamically
> add markers to my map ?
>
>
> Antoine
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131128/817d5f00/attachment.html>
More information about the Devel
mailing list