无法在使用SAP UI5创建的应用程序内呈现javascript HERE Maps API v3.1

问题描述 投票:0回答:1

我正在尝试在我的SAP UI5应用程序之一中呈现地图。我按照文档进行操作,之后便可以初始化H.service.Platform。但是,当我初始化H.Map()时,地图不会渲染。调试后发现有电话制作了https://js.hereapi.com/v3/3.1.9.0/styles/omv/normal.day.yaml?xnlp=CL_JSMv3.1.9.0&apikey=myApiKey,但由于找不到该地址而失败。

因此,我试图构建一个正常的HTML项目,该项目运行良好。经过调试发现对相同的要求是https://js.api.here.com/v3/3.1//styles/omv/normal.day.yaml

您可以看到URL有所不同。

我尝试将H.service.Platform()中的baseUrl参数设置为baseUrl: new H.service.Url('https', 'api.here.com')。这适用于上述请求,但是其余请求现在失败。例如https://1.base.maps.ls.hereapi.com/maptile/2.1/info?xnlp=CL_JSMv3.1.9.0&apikey=myApiKey&output=json失败

((在设置baseUrl参数之前有效)

使用的代码是

if (H) {
            var platform = new H.service.Platform({
                apikey: myApiKey
                    /*,
                                        baseUrl: new H.service.Url('https', 'api.here.com')*/
            });

            // Get an object containing the default map layers:
            var defaultLayers = platform.createDefaultLayers();

            // Instantiate the map using the vecor map with the
            // default style as the base layer:
            var map = new H.Map(this.byId("mapBox").getDomRef(),
                defaultLayers.vector.normal.map, {
                    center: {
                        lat: 50,
                        lng: 5
                    },
                    zoom: 4,
                    pixelRatio: window.devicePixelRatio || 1
                });

            var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));

            // Create the default UI components
            var ui = H.ui.UI.createDefault(map, defaultLayers);
        }

感谢与问候,Akshay

javascript here-api
1个回答
1
投票

此问题很难重现,因为它是在特定框架内发生的,但是在创建defaultLayers之后,尝试重新设置矢量法线贴图图层的样式:

defaultLayers.vector.normal.map.getProvider().setStyle(
  new H.map.Style('https://js.api.here.com/v3/3.1/styles/omv/normal.day.yaml')
);
© www.soinside.com 2019 - 2024. All rights reserved.