Frage

I've got a Qt program where a user can select the location by Google Maps. I'm using a simple HTML file for creating the map and load this file in the QWebView control:

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        html
        {
            height: 100%;
        }
        body
        {
            height: 100%;
            margin: 0;
            padding: 0;
        }
        #map_canvas
        {
            height: 100%;
        }
    </style>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
        function initialize() {
            var latlng = new google.maps.LatLng(-34.397, 150.644);

            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

            google.maps.event.addListener(map, "click", function (event) {

                var geoLocationUrl = 'http://maps.googleapis.com/maps/api/geocode/xml?latlng='
                + event.latLng.lat() + "," + event.latLng.lng() + "&sensor=false";

                console.log(geoLocationUrl);

                $.ajax({
                    type: "GET",
                    url: geoLocationUrl,
                    dataType: "xml",
                    success: function (xml) {

                    },
                    error: function () {

                    }


                });
            });
        }

        function showLocation(location) {

        }

    </script>
</head>
<body onload="initialize()">
    <div id="map_canvas" style="width: 100%; height: 100%">
    </div>
</body>
</html>

The question is how to pass data after an ajax request to the Qt C++ code. I know that I can evalute a javascript function in Qt C++ but in this case the task is reverse.

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top