如何使用(markerInfoWindowTapped)使用Nativescript在其他组件中导航

时间:2019-07-09 11:22:16

标签: routing nativescript google-maps-markers

我正在使用此plugin

在此插件中为markerInfoWindowTapped Fired on tapping Marker Info Window

当我单击该markerInfoWindow时,我想在另一个组件中进行导航。

因此,在html中,我有以下代码:

<GridLayout>
    <MapView  (mapReady)="onMapReady($event)" (markerInfoWindowTapped)="onMarkerEvent($event)"></MapView>
</GridLayout>

在.ts中,我有此代码

onMapReady(event) {
        console.log('OnMapReady')
        this.mapView = event.object;
        this.gMap = event.object.gMap;
        var UiSettings = this.gMap.getUiSettings();
        this.gMap.setMyLocationEnabled(true);
        UiSettings.setZoomControlsEnabled(true);
        this.itemsS = this.itemService.getItems();
        for (let i = 0; i < this.itemsS.length; i++) {
            this.myid=this.itemsS[i].id;
            console.log('this.myid', this.myid)
            console.log('OnMapReady pas for')
            var marker = new Marker();
            marker.position = Position.positionFromLatLng(this.itemsS[i].latitude, this.itemsS[i].longitude);
            marker.title = this.itemsS[i].name;
            marker.infoWindowTemplate = '/details/' + this.itemsS[i].id;
            this.mapView.addMarker(marker);
        }
        this.mapView.longitude = this.currentGeoLocation.longitude;
        this.mapView.latitude = this.currentGeoLocation.latitude;
        this.mapView.zoom = 15;
    }

    onMarkerEvent(event) {
        console.log(event.marker.infoWindowTemplate)
        this.router.navigate(event.marker.infoWindowTemplate);   
    }

对我来说,单击其他组件时很重要。我的代码正确吗?这不起作用,并显示J S: ERROR TypeError: e.reduce is not a function

您能否提出任何想法,当我单击标记时如何在其他组件中导航?

0 个答案:

没有答案