0

我正在尝试实现一个简单的谷歌地图演示。请求许可后,它在浏览器上完美显示。在 tizen 模拟器上,地图不显示,我的位置图标在右上角闪烁。

这是我的代码:

<!DOCTYPE html>
<html>
<head>
    <title>map demo</title>

    <style>
      #map {
        width: 100%;
        height: 400px;
        background-color: grey;
      }
    </style>





</head>
<body>

    <h3>My Google Maps Demo</h3>
    <!--The div element for the map -->
    <div id="map"></div>



<script>
// Initialize and add the map
function initMap() {

navigator.geolocation.getCurrentPosition(function(position) {

    console.log('Latitude: ' + position.coords.latitude  + 'Longitude: ' + position.coords.longitude);
    var uluru = {lat: position.coords.latitude, lng: position.coords.longitude};

      var map = new google.maps.Map(
      document.getElementById('map'), {zoom: 4, center: uluru});
  // The marker, positioned at Uluru
  var marker = new google.maps.Marker({position: uluru, map: map});

}, function(error) {
    console.error('GPS error occurred');
});

  // The location of Uluru

  // The map, centered at Uluru

}
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/jskey=MYKEYHERE&callback=initMap">
    </script>


</body>
</html>

这是我的配置:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="http://yourdomain/CoTakwira" version="1.0.0" viewmodes="maximized">
    <access origin="http://googleapis.com" subdomains="true"></access>
    <access origin="http://gstatic.com" subdomains="true"></access>
    <access origin="http://google.com" subdomains="true"></access>
    <tizen:application id="TIounxF6Sw.CoTakwira" package="TIounxF6Sw" required_version="3.0"/>
    <content src="index.html"/>
    <feature name="http://tizen.org/feature/screen.size.all"/>
    <icon src="icon.png"/>
    <name>CoTakwira</name>
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
    <tizen:privilege name="http://tizen.org/privilege/location"/>
    <tizen:profile name="mobile"/>
</widget>

这就是我在 tizen 模拟器上得到的

在此处输入图像描述

谢谢您的帮助

4

2 回答 2

0

请在您的config.xml中添加这些

<access origin="*" subdomains="true"/>
<tizen:allow-navigation>*<tizen:allow-navigation/>
<tizen:content-security-policy>self</tizen:content-security-policy>

检查此以了解有关定义外部访问策略的更多信息。

于 2018-11-06T06:37:37.200 回答
0

请按照此链接中提示文档中描述的步骤进行操作。另外请尝试在项目的 config.xml 文件中添加以下行。希望它会有所帮助。

<access origin="*" subdomains="true"/>
于 2018-11-02T06:15:25.673 回答