Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps Ionic Google地图在设备或-l实验室视图中不工作,但在浏览器中工作_Google Maps_Ionic Framework_Ionic3_Ionic View_Google Geolocation - Fatal编程技术网

Google maps Ionic Google地图在设备或-l实验室视图中不工作,但在浏览器中工作

Google maps Ionic Google地图在设备或-l实验室视图中不工作,但在浏览器中工作,google-maps,ionic-framework,ionic3,ionic-view,google-geolocation,Google Maps,Ionic Framework,Ionic3,Ionic View,Google Geolocation,我正在使用google map place api创建一家附近的餐厅,但当它在浏览器视图中启动时,它工作正常,但在设备或实验室视图中不工作。我正在尝试在google github stackoverflow上搜索所有内容,但没有任何效果。请帮助我解决此问题并拯救我的生命。 先谢谢你 问题是在地理定位功能策略中,我尝试了一切,但什么也解决不了我的问题。 我觉得我的home.ts页面代码有问题,但我不知道真正的问题是什么。 Home.html <ion-content> <

我正在使用google map place api创建一家附近的餐厅,但当它在浏览器视图中启动时,它工作正常,但在设备或实验室视图中不工作。我正在尝试在google github stackoverflow上搜索所有内容,但没有任何效果。请帮助我解决此问题并拯救我的生命。 先谢谢你

问题是在地理定位功能策略中,我尝试了一切,但什么也解决不了我的问题。 我觉得我的home.ts页面代码有问题,但我不知道真正的问题是什么。

Home.html

<ion-content>

  <div #map id="map"></div> 

  <div style="width : 100% ;height: 60%">
      <ion-list>

      <ion-item *ngFor="let place of places">
          <h4>{{place.name}}</h4>
          <p>{{place.vicinity}}</p>
          <p>Rating {{place.rating}}</p>
          <button ion-button clear item-end *ngIf="(place.opening_hours && !place.opening_hours.open_now)">CLOSED</button>
          <button ion-button clear item-end *ngIf="(place.opening_hours && place.opening_hours.open_now)">OPEN NOW</button>
      </ion-item>
      </ion-list>

  </div>


  </ion-content>


Index.html

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <title>Shapekit</title>
  <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">

  <link rel="icon" type="image/x-icon" href="assets/icon/logo.png">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">

  <!-- add to homescreen for ios -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <!-- cordova.js required for cordova apps (remove if not needed) -->
  <script src="cordova.js"></script>

  <!-- un-comment this code to enable service worker
  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </script>-->

  <link href="build/main.css" rel="stylesheet">

  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </script>

</head>
<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>


  <script src="http://maps.google.com/maps/api/js?key=APIKEY&libraries=places"></script>

</body>
</html>

代替使用IVIEVIEWDITENT,考虑使用平台服务:


IonViewDiCenter方法基于导航。因此,为了确保在设备准备就绪时实际运行代码,使用平台服务。

未使用其显示黑白屏幕,错误为:polyfills.js:2地理位置访问因应用于当前文档的功能策略而被阻止。错误->polyfills.js:2地理位置访问因应用于当前文档的功能策略而被阻止。有关更多详细信息,请参阅:goo.gl/EuHzyv。应用这些更改是否适用于您?。不是的,还有另外一个地图库,被几家公司使用。请描述问题。问题是当我放置此代码平台时。就绪。然后=>{this.getUserPosition;lab-l或apk视图中没有显示地图,但显示灰色页面,但没有显示地图,控制台中的错误是:polyfills.js:2由于应用于当前文档的功能策略,地理位置访问已被阻止。
<ion-content>

  <div #map id="map"></div> 

  <div style="width : 100% ;height: 60%">
      <ion-list>

      <ion-item *ngFor="let place of places">
          <h4>{{place.name}}</h4>
          <p>{{place.vicinity}}</p>
          <p>Rating {{place.rating}}</p>
          <button ion-button clear item-end *ngIf="(place.opening_hours && !place.opening_hours.open_now)">CLOSED</button>
          <button ion-button clear item-end *ngIf="(place.opening_hours && place.opening_hours.open_now)">OPEN NOW</button>
      </ion-item>
      </ion-list>

  </div>


  </ion-content>


Index.html

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <title>Shapekit</title>
  <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">

  <link rel="icon" type="image/x-icon" href="assets/icon/logo.png">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">

  <!-- add to homescreen for ios -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <!-- cordova.js required for cordova apps (remove if not needed) -->
  <script src="cordova.js"></script>

  <!-- un-comment this code to enable service worker
  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </script>-->

  <link href="build/main.css" rel="stylesheet">

  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </script>

</head>
<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>


  <script src="http://maps.google.com/maps/api/js?key=APIKEY&libraries=places"></script>

</body>
</html>
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';

@Component({...})
export MyApp {
  constructor(public plt: Platform) {
    this.plt.ready().then((readySource) => {

      this.getUserPosition();

    });
  }
}