Best Way to Access Google Maps API on QML



  • Hi everyone,
    I'm trying to display a Map using the Google Maps API (GOOGLE MAPS API).
    There I see that the Javascript API using HTML is quite easy.

    With this simple HTML file you could get the Google Maps Map:

    <!DOCTYPE html>
    <html>
      <head>
        <title>Simple Map</title>
        <meta name="viewport" content="initial-scale=1.0">
        <meta charset="utf-8">
        <style>
          html, body {
            height: 100%;
            margin: 0;
            padding: 0;
          }
          #map {
            height: 100%;
          }
        </style>
      </head>
      <body>
        <div id="map"></div>
        <script>
    
    var map;
    function initMap() {
      map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        zoom: 8
      });
    }
    
        </script>
        <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
            async defer></script>
      </body>
    </html>
    

    So, if I want to use this API in QML, which is the best way?
    Using a WebView to load this HTML file?
    Is there a more native way to get that?

    Thank you very much!


  • Qt Champions 2016

    There's a contributed plugin (somewhere in the Showcase forum) that implements a plugin for the QtLocation module.



  • Is there a reason you want to specifically use Google Maps? There are a multitude of providers already with Qt Location, including Esri, Here, and Mapbox. In addition, Esri provides a full mapping/location SDK that goes far beyond Qt Location capabilities - https://developers.arcgis.com/qt/


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.