Results 1 to 2 of 2

Thread: Displaying a Google Map, show directions and display pointer using Google Map APIs in

  1. #1

    Default Displaying a Google Map, show directions and display pointer using Google Map APIs in

    I am new to QML. The requirement is to display the Google Map, show directions for the given source and destinations and accept the GPS coordinates to display the pointer.

    PLease suggest a way to acheive this.

    My approaches and work-arounds:

    I was atleast first targetting to display a Google Map in the QML file output, for which, i tried to make use of the WebView component of QML as below. But here if i directly give the Google Maps url, it willdisplay a blank screen, otherwise if i give google.com, it display the google welcome page. After enough surfing, I am assuming the reason behind this is, to make use of the Google Map APIs to display the Map even in QML or in Android or in any otehr platform, we need to register with google apis and obtain a API key and etc stuff.



    import QtQuick 2.0
    import QtWebKit 3.0

    Rectangle {
    id: content
    width: 800
    height: 600
    color: "black"

    WebView {
    id: webView
    anchors.fill: parent
    url: "test.html"
    // url:"https://maps.googleapis.com/maps"
    }
    }


    Then i tried to display using webview, wherein, the url parameter takes input as an html file, which html file has the code including the API key to show the Google Maps. But still a blank screen int he qml result is given. A point to note here is, when i try to open that html file using a browser, it displays the Map.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlDpbqfg9cSMR 3KXz_MEb3hTA3oYWjJAjbd03R2NWMUuUP2WaqRQoF0m5cqrl1X cMH6kLmPtzm4ppLw" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    var map;
    function load() {
    if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(-21.4708, -47.0006), 14);
    map.setUIToDefault();
    }
    }
    //]]>
    </script>
    </head>
    <body onload="load()" onunload="GUnload()" topmargin="0" leftmargin="0">
    <div id="map" style="width: 800px; height: 600px"></div>
    </body>
    </html>



    I am not finding the secret behind all these. Please someone suggest me a solution for this.

  2. #2
    Join Date
    Oct 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Displaying a Google Map, show directions and display pointer using Google Map API

    Hi Nagini, Did you get a reply for this ?

Similar Threads

  1. Show user current location on google map in android
    By hasti in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2014, 15:51
  2. Google Direction can not display
    By thanhluanbk88 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 10th April 2011, 14:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.