Angular Google Places API-启用CORS-离子2+;角度2

Angular Google Places API-启用CORS-离子2+;角度2,angular,typescript,ionic2,wkwebview,Angular,Typescript,Ionic2,Wkwebview,我使用Http对象从GooglePlacesAPI请求数据。一切正常,但在安装了WkWebView插件之后,我遇到了CORS问题 有没有办法在没有服务器的情况下启用cors?或者我可以使用jsonp?有没有关于如何做到这一点的例子 这是我的密码: import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; @Injectable

我使用Http对象从GooglePlacesAPI请求数据。一切正常,但在安装了WkWebView插件之后,我遇到了CORS问题

有没有办法在没有服务器的情况下启用cors?或者我可以使用jsonp?有没有关于如何做到这一点的例子

这是我的密码:

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class PlacesService {

  // Geolocation object
    locator: any = null;

  constructor(public http: Http) {}

  search(place: string) {

    console.log('searchPlace', place, encodeURIComponent(place));

    return new Promise(resolve => {

      this.http.get('https://maps.googleapis.com/maps/api/place/textsearch/json?key=MYAPIKEY&query=' + encodeURIComponent(place))
      .map( res => res.json() )
      .subscribe( data => {
        resolve(data);
      });

    }); // Promise
  }
}

谢谢

在index.html中是否添加了内容安全策略标记?如果尚未添加,请尝试添加它。不,它不起作用,也许你知道如何在Angular 2中使用jsonp吗?当我添加到我的应用程序,称为Twitter和Stackoverflow API时,它对我起作用了。不,我知道如何在Angular2中使用jsonp。在WkWebView中?我认为这是不可能的:在你的index.html中,你添加了内容安全策略标签了吗?如果尚未添加,请尝试添加它。不,它不起作用,也许你知道如何在Angular 2中使用jsonp吗?当我添加到我的应用程序,称为Twitter和Stackoverflow API时,它对我起作用了。不,我知道如何在Angular2中使用jsonp。在WkWebView中?我认为这是不可能的