How to get Address.text?
-
Hi!
How to get Address.text?
I need the coordinates and house numbers on the visible side of the map. Here is my code:import QtQuick 2.12 import QtQuick.Window 2.12 import QtLocation 5.12 import QtPositioning 5.12 Item { visible: true width: 480 height: 720 property double old : 19 property double now Rectangle { anchors.fill: parent color: "#eee" PositionSource { id: src } Address { id: address } Plugin { id: plugin name: "osm" PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" } PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" } PluginParameter { name: "osm.mapping.copyright"; value: "All mine" } PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" } PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" } PluginParameter { name: "osm.places.host"; value: "http://geocoding.server.address" } } Map { id: maps anchors.fill: parent plugin: plugin gesture.enabled: true gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture gesture.flickDeceleration: 3000 zoomLevel: 19 center: QtPositioning.coordinate(59.91, 10.75) // Oslo onZoomLevelChanged: { console.log("onZoomLevelChanged:") console.log("coordinate ctnter:" + visibleRegion.center()) console.log("coordinate geoshape:" + visibleRegion.boundingGeoRectangle()) } onCenterChanged: { console.log("onCenterChanged:") console.log("coordinate ctnter:" + visibleRegion.center()) console.log("coordinate geoshape:" + visibleRegion.boundingGeoRectangle()) console.log("address:" ) } minimumZoomLevel: 1 focus: true } } }
-
@Mikeeeeee said in How to get Address.text?:
How to get Address.text?
I would say
address.text
or what do you mean?
-
@Mikeeeeee said in How to get Address.text?:
I need the house numbers and their coordinates on the visible side of the map
I never used QLocation/QPositioning, but I think you must first connect the Adress item with the Map. I don't know how you have to do it... But this seems to me to be the first step to do.
I think you have to connect theAddress.address
property... but I don't really known :( -
It turned out the address can be obtained so, but there are no coordinates and house numbers. Do you know where the coordinates and house numbers might be?
import QtQuick 2.12 import QtQuick.Window 2.12 import QtLocation 5.12 import QtPositioning 5.12 Item { visible: true width: 480 height: 720 property double old : 19 property double now Rectangle { anchors.fill: parent color: "#eee" Plugin { id: plugin name: "osm" //PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" } } Map { id: maps anchors.fill: parent plugin: plugin gesture.enabled: true gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture gesture.flickDeceleration: 3000 zoomLevel: 19 center: QtPositioning.coordinate(59.91, 10.75) // Oslo onCenterChanged: { geocodeModel.query = visibleRegion.center() geocodeModel.update() } minimumZoomLevel: 1 focus: true GeocodeModel { id: geocodeModel plugin: plugin onLocationsChanged: { console.log("onLocationsChanged") if (count == 1) { console.log("street:" + geocodeModel.get(0).address.street ) console.log("district:" + geocodeModel.get(0).address.district ) console.log("city:" + geocodeModel.get(0).address.city ) console.log("county:" + geocodeModel.get(0).address.county ) console.log("state:" + geocodeModel.get(0).address.state ) console.log("countryCode:" + geocodeModel.get(0).address.countryCode ) console.log("country:" + geocodeModel.get(0).address.country ) console.log("postalCode:" + geocodeModel.get(0).address.postalCode ) //console.log("postalCode:" + geocodeModel.get(0).address.text ) } } } } } }