GeocodeModel in Qt
I'm writing a the little app with using the QT/QML, and i have problem with GeocodeModel in my app. I don't know, why it doesn't work. I did it with YT tutorial, but by the man it works.
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
ApplicationWindow {
id: app_window
visible: true
width: 1024
height: 800
title: qsTr("Navigation")
PositionSource {
active: true
onPositionChanged: {
map_id.center = position.coordinate;
}
}
Rectangle {
id: mapRectangleID
width: 1024
height: 800
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Map {
id: map_id
anchors.fill: parent
plugin: Plugin { name: "osm" }
center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
zoomLevel: 15
MapQuickItem {
//coordinate: QtPositioning.coordinate(59.91, 10.75)
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 40.1
height: 34.3
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
RouteModel {
id: routeBetweenPoints
plugin: Plugin { name: "osm" }
query: RouteQuery {id: routeQuery }
Component.onCompleted: {
routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
//routeQuery.addWaypoint(endPointGeaocodeModel)
update();
}
} //start and end point
MapItemView {
model: routeBetweenPoints
delegate: Component {
MapRoute {
route: routeData
line.color: "red"
line.width: 10
}
}
}//linie, die beide punkte verbindet
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
Rectangle{
id:_ifStartPointLongitude
width: 100
height: 20
border.color: 'gray'
border.width: 2
x: 900
y: 120
anchors.left: app_window.right
TextInput {
id: txtPlainStartPointLongitude
anchors.fill: parent
anchors.margins: 4
}
}
} //all widgets and items of map
} //size and position of map
}
and This element doesn't work:
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
I tried too another cities,streets, but it still doesn't work. Can someone explain me, what i did/wrote wrong?
qt qml qt5 openstreetmap geocode
add a comment |
I'm writing a the little app with using the QT/QML, and i have problem with GeocodeModel in my app. I don't know, why it doesn't work. I did it with YT tutorial, but by the man it works.
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
ApplicationWindow {
id: app_window
visible: true
width: 1024
height: 800
title: qsTr("Navigation")
PositionSource {
active: true
onPositionChanged: {
map_id.center = position.coordinate;
}
}
Rectangle {
id: mapRectangleID
width: 1024
height: 800
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Map {
id: map_id
anchors.fill: parent
plugin: Plugin { name: "osm" }
center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
zoomLevel: 15
MapQuickItem {
//coordinate: QtPositioning.coordinate(59.91, 10.75)
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 40.1
height: 34.3
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
RouteModel {
id: routeBetweenPoints
plugin: Plugin { name: "osm" }
query: RouteQuery {id: routeQuery }
Component.onCompleted: {
routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
//routeQuery.addWaypoint(endPointGeaocodeModel)
update();
}
} //start and end point
MapItemView {
model: routeBetweenPoints
delegate: Component {
MapRoute {
route: routeData
line.color: "red"
line.width: 10
}
}
}//linie, die beide punkte verbindet
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
Rectangle{
id:_ifStartPointLongitude
width: 100
height: 20
border.color: 'gray'
border.width: 2
x: 900
y: 120
anchors.left: app_window.right
TextInput {
id: txtPlainStartPointLongitude
anchors.fill: parent
anchors.margins: 4
}
}
} //all widgets and items of map
} //size and position of map
}
and This element doesn't work:
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
I tried too another cities,streets, but it still doesn't work. Can someone explain me, what i did/wrote wrong?
qt qml qt5 openstreetmap geocode
add a comment |
I'm writing a the little app with using the QT/QML, and i have problem with GeocodeModel in my app. I don't know, why it doesn't work. I did it with YT tutorial, but by the man it works.
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
ApplicationWindow {
id: app_window
visible: true
width: 1024
height: 800
title: qsTr("Navigation")
PositionSource {
active: true
onPositionChanged: {
map_id.center = position.coordinate;
}
}
Rectangle {
id: mapRectangleID
width: 1024
height: 800
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Map {
id: map_id
anchors.fill: parent
plugin: Plugin { name: "osm" }
center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
zoomLevel: 15
MapQuickItem {
//coordinate: QtPositioning.coordinate(59.91, 10.75)
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 40.1
height: 34.3
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
RouteModel {
id: routeBetweenPoints
plugin: Plugin { name: "osm" }
query: RouteQuery {id: routeQuery }
Component.onCompleted: {
routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
//routeQuery.addWaypoint(endPointGeaocodeModel)
update();
}
} //start and end point
MapItemView {
model: routeBetweenPoints
delegate: Component {
MapRoute {
route: routeData
line.color: "red"
line.width: 10
}
}
}//linie, die beide punkte verbindet
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
Rectangle{
id:_ifStartPointLongitude
width: 100
height: 20
border.color: 'gray'
border.width: 2
x: 900
y: 120
anchors.left: app_window.right
TextInput {
id: txtPlainStartPointLongitude
anchors.fill: parent
anchors.margins: 4
}
}
} //all widgets and items of map
} //size and position of map
}
and This element doesn't work:
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
I tried too another cities,streets, but it still doesn't work. Can someone explain me, what i did/wrote wrong?
qt qml qt5 openstreetmap geocode
I'm writing a the little app with using the QT/QML, and i have problem with GeocodeModel in my app. I don't know, why it doesn't work. I did it with YT tutorial, but by the man it works.
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
ApplicationWindow {
id: app_window
visible: true
width: 1024
height: 800
title: qsTr("Navigation")
PositionSource {
active: true
onPositionChanged: {
map_id.center = position.coordinate;
}
}
Rectangle {
id: mapRectangleID
width: 1024
height: 800
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Map {
id: map_id
anchors.fill: parent
plugin: Plugin { name: "osm" }
center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
zoomLevel: 15
MapQuickItem {
//coordinate: QtPositioning.coordinate(59.91, 10.75)
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 40.1
height: 34.3
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
RouteModel {
id: routeBetweenPoints
plugin: Plugin { name: "osm" }
query: RouteQuery {id: routeQuery }
Component.onCompleted: {
routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
//routeQuery.addWaypoint(endPointGeaocodeModel)
update();
}
} //start and end point
MapItemView {
model: routeBetweenPoints
delegate: Component {
MapRoute {
route: routeData
line.color: "red"
line.width: 10
}
}
}//linie, die beide punkte verbindet
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
Rectangle{
id:_ifStartPointLongitude
width: 100
height: 20
border.color: 'gray'
border.width: 2
x: 900
y: 120
anchors.left: app_window.right
TextInput {
id: txtPlainStartPointLongitude
anchors.fill: parent
anchors.margins: 4
}
}
} //all widgets and items of map
} //size and position of map
}
and This element doesn't work:
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count)
endPointImage.coordinate = get(0).coordinate;
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
I tried too another cities,streets, but it still doesn't work. Can someone explain me, what i did/wrote wrong?
qt qml qt5 openstreetmap geocode
qt qml qt5 openstreetmap geocode
edited Dec 2 '18 at 20:15
eyllanesc
78.9k103257
78.9k103257
asked Nov 20 '18 at 5:46
DragonCoderDragonCoder
177
177
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The problem is caused because the item Image does not have the coordinate property, the one who has the coordinate property is the MapQuickItem, so we must set it to that item so we must give an id to the MapQuickItem, to observe the image we will establish the center of the map to the same coordinate.
// ...
MapQuickItem {
id: marker_id // <---
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 100
height: 100
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
// ...
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count> 0){
marker_id.coordinate = get(0).coordinate // <----
map_id.center = get(0).coordinate // <----
}
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
// ...
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
|
show 11 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386929%2fgeocodemodel-in-qt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is caused because the item Image does not have the coordinate property, the one who has the coordinate property is the MapQuickItem, so we must set it to that item so we must give an id to the MapQuickItem, to observe the image we will establish the center of the map to the same coordinate.
// ...
MapQuickItem {
id: marker_id // <---
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 100
height: 100
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
// ...
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count> 0){
marker_id.coordinate = get(0).coordinate // <----
map_id.center = get(0).coordinate // <----
}
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
// ...
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
|
show 11 more comments
The problem is caused because the item Image does not have the coordinate property, the one who has the coordinate property is the MapQuickItem, so we must set it to that item so we must give an id to the MapQuickItem, to observe the image we will establish the center of the map to the same coordinate.
// ...
MapQuickItem {
id: marker_id // <---
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 100
height: 100
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
// ...
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count> 0){
marker_id.coordinate = get(0).coordinate // <----
map_id.center = get(0).coordinate // <----
}
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
// ...
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
|
show 11 more comments
The problem is caused because the item Image does not have the coordinate property, the one who has the coordinate property is the MapQuickItem, so we must set it to that item so we must give an id to the MapQuickItem, to observe the image we will establish the center of the map to the same coordinate.
// ...
MapQuickItem {
id: marker_id // <---
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 100
height: 100
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
// ...
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count> 0){
marker_id.coordinate = get(0).coordinate // <----
map_id.center = get(0).coordinate // <----
}
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
// ...
The problem is caused because the item Image does not have the coordinate property, the one who has the coordinate property is the MapQuickItem, so we must set it to that item so we must give an id to the MapQuickItem, to observe the image we will establish the center of the map to the same coordinate.
// ...
MapQuickItem {
id: marker_id // <---
sourceItem: Image {
id: endPointImage
source: "assets/marker.png"
width: 100
height: 100
} //size and position of maker
anchorPoint.x: endPointImage.width / 2
anchorPoint.y: endPointImage.height
} //marker
// ...
GeocodeModel{
id: endPointGeaocodeModel
plugin: Plugin { name: "osm" }
query: "Sandakerveien 116, Oslo"
onLocationsChanged: {
if (count> 0){
marker_id.coordinate = get(0).coordinate // <----
map_id.center = get(0).coordinate // <----
}
}
Component.onCompleted: update()
} //suche den platz mit strasse und stadt
// ...
answered Nov 20 '18 at 6:08
eyllanesceyllanesc
78.9k103257
78.9k103257
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
|
show 11 more comments
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
Ok, i thought all the time, that i shuld write the id of the image and not of the MapQuickItem
– DragonCoder
Nov 20 '18 at 6:16
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
It still doesnt work
– DragonCoder
Nov 20 '18 at 6:24
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder how strange, I tested it and it works correctly, in the following image I show you the result: imgur.com/a/FBFMTt0
– eyllanesc
Nov 20 '18 at 6:27
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
@DragonCoder could you show me a picture of what you get
– eyllanesc
Nov 20 '18 at 6:28
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
imgur.com/a/IG1vYND
– DragonCoder
Nov 20 '18 at 6:31
|
show 11 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386929%2fgeocodemodel-in-qt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown