Карта не отображается на эмуляторе - PullRequest
0 голосов
/ 02 ноября 2018

Я пытаюсь реализовать простую демонстрацию карт Google. Он отлично отображается в браузере после запроса разрешения. В эмуляторе 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

enter image description here

Спасибо за вашу помощь

Ответы [ 2 ]

0 голосов
/ 06 ноября 2018

Пожалуйста, добавьте их в config.xml

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

Установите этот флажок , чтобы узнать больше об определении политик внешнего доступа.

0 голосов
/ 02 ноября 2018

Пожалуйста, следуйте шагам, описанным в документе наконечника здесь эта ссылка . Также попробуйте добавить строку ниже в файле config.xml проекта. Надеюсь, это поможет.

<access origin="*" subdomains="true"/>
...