Help google maps


#1

necesito una ayuda, saben si a ustedes le sirvio este plugin. Está tratando de incluirlo en mi proyecto y me da error:
JS: TypeError: no se puede leer la propiedad 'Lugares' de indefinido

No se si el plugin es que no sirve o algo que estoy haciendo mal


#2

Can you paste the full error log & code snippet?


#3

Hi, @manojdcoder

ERROR

JS: TypeError: Cannot read property ‘Places’ of undefined

this is the only error message when I press the button and I do not get the map or the search engine. I wanted to know if you have tried this plugin for google maps or what you recommend. Since I want to do an autocomplete of places

Component

import { Component } from "@angular/core";
import * as GooglePlaces from 'nativescript-plugin-google-places';
import { ImageSource } from 'image-source';
import * as platform from "tns-core-modules/platform";


@Component({
    selector: "ns-app",
    templateUrl: "app.component.html",
})

export class AppComponent {

    place: GooglePlaces.Place;

    staticMapUrl: string;

    constructor() {
        GooglePlaces.init();

        setTimeout(() => {
            GooglePlaces.getPlacesById([
                "ChIJ4zPXqIiAhYAR31X3S64T6Uw",
                "ChIJ6zMe3oWAhYARaZ33Z1BAMRo",
                "ChIJAUWoGIaAhYARQ6zvky_f10Q"
            ])
                .then((places: GooglePlaces.Place[]) => {
                    places.forEach(place => console.log(place.name));
                })
                .catch(error => console.log(error));
        }, 1000)
    }

    pickPlace(): void {
        GooglePlaces.pickPlace()
            .then(place => {
                this.place = place;
                console.log(place.types);
                
                this.staticMapUrl = GooglePlaces.getStaticMapUrl(place, { width: platform.screen.mainScreen.widthDIPs, height: 250 });
            })
            .catch(error => console.log(error));
    }
}
.```
HTML
<StackLayout>
    <Button text="Pick place" (tap)="pickPlace()"></Button>
    <StackLayout *ngIf="place">
        <Label text="You picked:"></Label>
        <Label [text]="place.name"></Label>
        <Label [text]="place.address"></Label>
        <Label *ngIf="place.attributions" [text]="place.attributions"></Label>
        <Label [text]="'ID: ' + place.id"></Label>
        <Label *ngFor="let type of place.types" [text]="type"></Label>
        <Image src="res://powered_by_google_dark" stretch="none" style="background-color: black;"></Image>
        <Image src="res://powered_by_google_light" stretch="none"></Image>
        <Image *ngIf="staticMapUrl" [src]="staticMapUrl" width="100%" height="250"></Image>
    </StackLayout>
</StackLayout>