小编j4r*_*rey的帖子

android模拟位置不适用于locationservices.fusedlocationapi

从谷歌商店下载并使用“Fake Gps”后,我想为教育目的创建一个。

我正在使用 GoogleApiClient FusedLocationAPI 来获取我的当前位置并创建一个模拟位置。我能够获得我当前的位置,但无法模拟位置。

public class GoogleApiClientGeoLocation implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
    private GoogleApiClient googleApiClient;

    public GoogleApiClientGeoLocation(Context activity) {
        googleApiClient = new GoogleApiClient.Builder(activity, this, this).addApi(LocationServices.API).build();
        ....
    }

    public void connect() {
        if (googleApiClient != null) {
           googleApiClient.connect();
        }
    }

    public void disconnect() {
        googleApiClient.disconnect();
    }

    @Override
    public void onConnected(@Nullable Bundle bundle) {
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }

    @Override
    public void onLocationChanged(Location location) {
        Log.e("TAG","Location changed"+location.getLatitude() + ", "+ location.getLongitude());
    }

    private static final String PROVIDER = LocationManager.NETWORK_PROVIDER;//"flp";
    private static …
Run Code Online (Sandbox Code Playgroud)

android location google-api-client fusedlocationproviderapi

5
推荐指数
1
解决办法
1178
查看次数

如何使用Angular Universal创建Angular自定义元素:SSR

我正在尝试使用Angular Universal创建一个Angular应用程序:SSRCustom Elements

我下载了Angular Universal:SSR中可用的示例代码,并向AppModule的构造函数中的Custom Elements添加了以下代码行

const ele = createCustomElement(AppComponent, {injector});
customElements.define('custom-ele', ele);
Run Code Online (Sandbox Code Playgroud)

它的构建很好,但是当我尝试为其提供服务时,出现以下错误

...universal\dist\server.js:66760
var elProto = Element.prototype;

ReferenceError: Element is not defined
at Object.<anonymous> (...universal\dist\server.js:66760:15)
at __webpack_require__ (...universal\dist\server.js:20:30)
....
Run Code Online (Sandbox Code Playgroud)

是因为Element是仅用于浏览器的本机对象,并且由于其在服务器端,因此无法引用仅用于浏览器的本机对象?有没有解决的办法?

angular-universal angular angular-elements

5
推荐指数
1
解决办法
548
查看次数