<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[solved] map zoomout and zoomin problem]]></title><description><![CDATA[<p dir="auto">i draw a icon in the map,but when the map zoomin and zoomout ,the icon's position does not moved and is always at that screen position.</p>
<p dir="auto">but if i moved the icon to another screen position.and zoomin or zoomout ,this icon moved incorrect,why?<br />
@<br />
import QtQuick 1.1<br />
import QtMobility.location 1.2</p>
<p dir="auto">Item {<br />
id: page<br />
anchors.fill: parent<br />
focus: true<br />
property int selectedIcon: -1; // selected icon</p>
<p dir="auto">property int xwitdh: 26; // icon width<br />
property int xhight: 26; // icon hight<br />
property int zoom_tmp;<br />
TitleBar { id: titleBar; appname: "Map Markers"; z: 5; width: parent.width; height: 40; opacity: 0.8 }</p>
<p dir="auto">function selectMarkerIcon(mx, my){</p>
<p dir="auto">{<br />
var topLeftPoint = map.toScreenPosition(maker.coordinate);</p>
<p dir="auto">var xStart = parseInt(topLeftPoint.x);<br />
var yStart = parseInt(topLeftPoint.y);</p>
<p dir="auto">if((mx &gt;= xStart) &amp;&amp; (my &gt;= yStart)<br />
&amp;&amp; (mx &lt;= (xStart + xwitdh)) &amp;&amp; (my &lt;= (yStart + xhight))){<br />
return 0;<br />
}<br />
}</p>
<p dir="auto">return -1;<br />
}</p>
<p dir="auto">Rectangle {<br />
id: dataArea<br />
anchors.top: titleBar.bottom<br />
anchors.bottom: parent.bottom<br />
width: parent.width<br />
color: "#343434"</p>
<p dir="auto">Map {<br />
id: map<br />
anchors.fill: parent<br />
zoomLevel: 10<br />
center: Coordinate {latitude: 52.45705; longitude: 13.41173}<br />
plugin: Plugin {<br />
name: "nokia"<br />
}</p>
<p dir="auto">MapImage {<br />
id:maker<br />
source: "images/button-green.png"<br />
coordinate: Coordinate {latitude: 52.45705; longitude: 13.41173}<br />
}<br />
}</p>
<p dir="auto">MouseArea {<br />
id: mousearea</p>
<p dir="auto">property bool __isPanning: false<br />
property int __lastX: -1<br />
property int __lastY: -1</p>
<p dir="auto">anchors.fill : parent</p>
<p dir="auto">onPressed: {</p>
<p dir="auto">selectedIcon = selectMarkerIcon(mouse.x,mouse.y)</p>
<p dir="auto">if(selectedIcon &gt;= 0 ){<br />
maker.source = "images/button-red.png";<br />
}else{<br />
__isPanning = true<br />
__lastX = mouse.x<br />
__lastY = mouse.y<br />
}<br />
}</p>
<p dir="auto">onReleased: {<br />
if(selectedIcon &gt;= 0){<br />
maker.source = "images/button-green.png";<br />
}<br />
selectedIcon = -1;</p>
<p dir="auto">__isPanning = false<br />
}</p>
<p dir="auto">onPositionChanged: {<br />
if(selectedIcon &gt;= 0 ){<br />
maker.coordinate = map.toCoordinate(Qt.point((mouse.x - (xwitdh / 2)),(mouse.y - (xhight / 2))));<br />
}else if (__isPanning) {<br />
var dx = mouse.x - __lastX<br />
var dy = mouse.y - __lastY<br />
map.pan(-dx, -dy)<br />
__lastX = mouse.x<br />
__lastY = mouse.y<br />
}<br />
}</p>
<p dir="auto">onCanceled: {<br />
if(selectedIcon &gt;= 0){<br />
maker.source = "images/button-green.png";<br />
}<br />
selectedIcon = -1;</p>
<p dir="auto">__isPanning = false;<br />
}<br />
}</p>
<p dir="auto">Rectangle {<br />
id: slidder<br />
anchors.top: parent.top<br />
anchors.right: parent.right<br />
anchors.rightMargin: 4;<br />
anchors.topMargin: 4;<br />
anchors.bottomMargin: 4;<br />
anchors.bottom: parent.bottom<br />
width: 20;<br />
border.color : "#555555"<br />
border.width : 2<br />
color: "#40000000"</p>
<p dir="auto">Rectangle {<br />
id: handle; width: 20; height: 20<br />
y: ((map.zoomLevel - map.minimumZoomLevel) * ((slidder.height - handle.height) / (map.maximumZoomLevel - map.minimumZoomLevel)));<br />
color: "white"<br />
MouseArea {<br />
anchors.fill: parent<br />
drag.target: parent; drag.axis: "YAxis"<br />
drag.minimumY: 0; drag.maximumY: slidder.height - handle.height</p>
<p dir="auto">onReleased:{<br />
zoom_tmp = map.minimumZoomLevel + (handle.y / ((slidder.height - handle.height) / (map.maximumZoomLevel - map.minimumZoomLevel)));<br />
map.zoomLevel = zoom_tmp;<br />
}<br />
}<br />
}<br />
}</p>
<p dir="auto">}</p>
<p dir="auto">} @</p>
<p dir="auto">[edit, typo in title fixed, please add @ code tags around your code as i did for you, Eddy]</p>
]]></description><link>https://forum.qt.io/topic/10984/solved-map-zoomout-and-zoomin-problem</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 13:36:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/10984.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Nov 2011 03:27:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] map zoomout and zoomin problem on Thu, 03 Nov 2011 07:37:52 GMT]]></title><description><![CDATA[<p dir="auto">i found the problem is th mapimage's offset.x and offset.y i have not to set for the image.thank you</p>
]]></description><link>https://forum.qt.io/post/115435</link><guid isPermaLink="true">https://forum.qt.io/post/115435</guid><dc:creator><![CDATA[yangzl]]></dc:creator><pubDate>Thu, 03 Nov 2011 07:37:52 GMT</pubDate></item></channel></rss>