简体   繁体   English

地图在设备上不起作用

[英]Map doesn't work on device

I spent a lot of time trying to figure this out. 我花了很多时间试图解决这个问题。 I have a map on my application and this map loads the actual location once it is loaded. 我在应用程序上有一张地图,该地图在加载后会加载实际位置。

For some reason on my viewer (using Ionic Viewer) it works on my local device and on my localhost, but When I test it on my iPhone directly from Xcode, the map don't load. 由于某种原因,在我的查看器(使用Ionic Viewer)上,它可以在本地设备和本地主机上运行,​​但是当我直接从Xcode在iPhone上对其进行测试时,地图不会加载。

If I compile an .apk and test it on android, the map don't load either. 如果我编译.apk并在android上对其进行测试,则地图也不会加载。

.controller('mapaCtrl', function($scope, $compile, $location) {

    $scope.goPayment = function() {
        $location.path('side-menu/history');
    };


var myLatlng = new google.maps.LatLng(34.603711, -58.381585);

    var mapOptions = {
        center: myLatlng,
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById("map"), mapOptions);

    navigator.geolocation.getCurrentPosition(function(pos) {
        map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
        var myLocation = new google.maps.Marker({
            position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
            map: map,
            title: "My Location"
        });

        google.maps.event.addListener(myLocation, 'click', function() {
            infowindow.open(map,myLocation);
        });
    });


    var contentString = "<div><a ng-click='clickTest()'>Pagar Aqui!</a></div>";
    var compiled = $compile(contentString)($scope);

    var infowindow = new google.maps.InfoWindow({
      content: compiled[0]
    });

  $scope.map = map;

      $scope.clickTest = function() {
    $location.path('side-menu/pay');
  };




})

Any clue? 有什么线索吗?

There may be several things affecting the proper functionality of your app, consider the following: 可能有几件事会影响您应用的正常功能,请考虑以下因素:

I'm not sure it's necessary to have these anymore but I know for Android you could verify the permissions needed to exist in AndroidManifest.xml: 我不确定是否有必要再添加这些,但我知道对于Android,您可以验证AndroidManifest.xml中所需的权限:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

There is probably some iOS equivalent that you can search for but I think installing the plugin should work on its own. 您可能可以搜索一些与iOS相当的产品,但我认为安装插件应该可以独立进行。

-- -

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM