0

I am trying to use Google Maps (with API key) as a map provider in sap.ui.vbm.GeoMap library in SAPUI5, but the maps are not being displayed. My API key is correct (checked with Google maps extension) and no error in console.

If I change my source URL to “https://mt.google.com/vt/x={X}&y={Y}&z={LOD}“, the map is being displayed, but I am not sure if this can be used for a production environment as this doesn’t have an API key. This is how I am using it in mapconfig:

var oMap = new sap.ui.vbm.GeoMap();
var oMapConfig = { 
           “MapProvider”: [{
                    “Id”: “GM”,
                    “name”: “Google Maps”,
                    “minLOD”: “1”,
                    “maxLOD”: “19”,
                    “tileX”: “256”,
                    “tileY”: “256”,
                    “copyright”: “© Google Maps”,
                    “Source”: [{
                      “id”: “a”,
                      “url”: “https://maps.googleapis.com/maps/api/js?key=My_API_Key”
                    }]
                }],
                “MapLayerStacks”: [{
                    “name”: “Default”,
                    “MapLayer”: [{
                        “name”: “Default”,
                        “refMapProvider”: “Google Maps”,
                        “opacity”: “1.0",
                        “colBkgnd”: “RGB(255,255,255)”
                    }]
                }]
            }; 


oMap.setMapConfiguration(oMapConfig); 
oMap.setRefMapLayerStack("Default");

Can someone help me with this, what I might be doing wrong or need to change? When I use Open Street Map in the same way, it works fine but not with Google Maps

ankur129
  • 9
  • 1

1 Answers1

0

I don't know if you still need an answer, but I just had some difficulties too with the implementation of the Google Maps API to the Geomap control of SAPUI5. I was able to find the solution so I'll write it down here for you and other developers.

Your code to config the map is fine, you only need the correct Source URL. This URL is very similar to the one you would change to get the map to be displayed.

https://mt1.googleapis.com/vt?x={X}&y={Y}&z={LOD}&key=API_KEY

Change 'API_KEY' to your key and you should be good to go.