Skip to content

Commit

Permalink
Click on place on map shows nearest place, not first in clickable dis…
Browse files Browse the repository at this point in the history
…tance; fixed "Show on map" button. Now it sets center of map to position of object
  • Loading branch information
Jozef Mlich committed Feb 5, 2015
1 parent bb79754 commit 8475c6b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 20 deletions.
4 changes: 4 additions & 0 deletions i18n/rh-devconf_cs_CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,9 @@
<source>Place</source>
<translation>Místo</translation>
</message>
<message id="map-page-show-current-position">
<source>Show current position</source>
<translation>Zobrazit současnou polohu</translation>
</message>
</context>
</TS>
4 changes: 4 additions & 0 deletions i18n/rh-devconf_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,9 @@
<source>Place</source>
<translation>Place</translation>
</message>
<message id="map-page-show-current-position">
<source>Show current position</source>
<translation>Show current position</translation>
</message>
</context>
</TS>
15 changes: 10 additions & 5 deletions qml/MapPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ Page {
map_visible = !map_visible;
}
}
MenuItem {
visible: map_visible
//% "Show current position"
text: qsTrId("map-page-show-current-position");
onClicked: {
map.setCenterLatLon(map.currentPositionLat, map.currentPositionLon);
}

}
}

PageHeader {
Expand Down Expand Up @@ -87,9 +96,7 @@ Page {
}
onClicked: {
showDetail(model.name, model.description, model.icon, model.lat, model.lon);
map.latitude = lat;
map.longitude = lon;

map.setCenterLatLon(lat, lon)
}
}
}
Expand All @@ -111,8 +118,6 @@ Page {

remorse.execute(name, function() {
showDetail(name, description, icon, lat, lon);
map.latitude = lat;
map.longitude = lon;
})

}
Expand Down
39 changes: 26 additions & 13 deletions qml/PinchMap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ Rectangle {
var local = Qt.resolvedUrl(F.getMapTile(localUrl, tx, ty, zoomLevel));
var remote = F.getMapTile(remoteUrl, tx, ty, zoomLevel);

// if (!file_reader.file_exists(local)) {
// console.log ("wget "+remote + " --output-document=" +local )
// }
// return remote;
// if (!file_reader.file_exists(local)) {
// console.log ("wget "+remote + " --output-document=" +local )
// }
// return remote;
return (file_reader.file_exists(local)) ? local : remote

}
Expand Down Expand Up @@ -524,7 +524,7 @@ Rectangle {
property int __firstX: -1;
property int __firstY: -1;
property bool __wasClick: false;
property int maxClickDistance: 100;
property int maxClickDistance: 80;

anchors.fill : parent;
preventStealing: true;
Expand All @@ -539,7 +539,7 @@ Rectangle {
pannedManually()

var distance = F.euclidDistance(targetIndicator.x, targetIndicator.y, mouse.x, mouse.y);
if (targetDragable && (distance < 80)) { // dragThreshold
if (targetDragable && (distance < maxClickDistance)) { // dragThreshold
__draging = true;
} else {
__isPanning = true;
Expand All @@ -553,14 +553,27 @@ Rectangle {

onReleased: {

// if not panning
if (F.euclidDistance(__firstX, __firstY, mouse.x, mouse.y) < 40) {
for (var i = 0; i < places.count; i++) {
var item = places.get(i);
var pos = getScreenpointFromCoord(item.lat, item.lon);
var distance = F.euclidDistance(mouse.x, mouse.y, pos[0], pos[1]);
if (distance < 80) {
if (F.euclidDistance(__firstX, __firstY, mouse.x, mouse.y) < 40) { // if not panning

// find nearest place
if (places.count > 0) {
var minIndex = 0;
var item = places.get(0);
var screen = getScreenpointFromCoord(item.lat, item.lon);
var distance = F.euclidDistance(mouse.x, mouse.y, screen[0], screen[1]);
var minDistance = distance;
for (var i = 1; i < places.count; i++) {
item = places.get(i)
screen = getScreenpointFromCoord(item.lat, item.lon);
distance = F.euclidDistance(mouse.x, mouse.y, screen[0], screen[1]);
if (distance < minDistance) {
minDistance = distance;
minIndex = i;
}
}

if (minDistance < maxClickDistance) {
item = places.get(minIndex);
mapItemClicked(item.name, item.description, item.icon, item.lat, item.lon)
}
}
Expand Down
2 changes: 1 addition & 1 deletion rpm/rh-devconf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Name: rh-devconf
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Developer Conference
Version: 0.6
Version: 0.7
Release: 1
Group: Qt/Qt
License: BSD
Expand Down
2 changes: 1 addition & 1 deletion rpm/rh-devconf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: rh-devconf
Summary: Developer Conference
Version: 0.6
Version: 0.7
Release: 1
Group: Qt/Qt
URL: http://www.devconf.cz/
Expand Down

0 comments on commit 8475c6b

Please sign in to comment.