Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addMarker won't work with @Input values for Angular on Android only #53

Closed
leocaseiro opened this issue Jul 28, 2016 · 1 comment
Closed

Comments

@leocaseiro
Copy link
Contributor

leocaseiro commented Jul 28, 2016

Hi @dapriett, thank you so much for this awesome module.

I'm using this module in my app and work perfectly on ios.

If I set static values for latitude and longitude(such your example), my marker works great.

However, If I set the latitude and longitude with @Input, the map shows in the correct position, but the function addMarker won't show any icon/image.

The weirdest thing is that I don't have any bug. It shows all directions and values on console.dump, but I can't see the marker...

Am I the only one with this issue?

PS: The issue is on Android only and with @Input values

@Component({
    selector: "my-map",
    template: `
<GridLayout rows="auto,*">
    <Button text="Add Marker" (tap)="addMarker($event)"></Button>
    <MapView row="1" (mapReady)="onMapReady($event)"
        [latitude]="latitude" [longitude]="longitude"
        [zoom]="zoom" [bearing]="bearing"
        [tilt]="tilt" [padding]="padding"
    ></MapView>
</GridLayout>
    `,
})
export class MyMap {
    @Input() latitude: any;  //works for the map only
    @Input() longitude: any; //works for the map only
    // latitude: number = -33.86; //works fine
    // longitude: number =  151.20;  //works fine

    zoom: number = 8;
    bearing: number = 0;
    tilt: number = 0;
    padding: Array<number> = [40, 40, 40, 40];

    coreMarker: any;

    @ViewChild("MapView") mapView: any;

    public addMarker(args) {
        console.log("Setting a marker...");
        console.log('latitude', this.latitude); //shows correctly
        console.log('longitude', this.longitude); //shows correctly

        var marker = new mapsModule.Marker();
        //marker.position = mapsModule.Position.positionFromLatLng(-33.86, 151.20); //works
        marker.position = mapsModule.Position.positionFromLatLng(this.latitude, this.longitude);
        marker.userData = {index: 1};
        this.mapView.addMarker(marker);
        // console.dump(marker); //shows correctly
    }

    public onMapReady(args) {
        console.log("onMapReady");

        this.mapView = args.object; // I've tried using nativeElement, same issue
    }

Component <my-map> usage:

<my-map [latitude]="address.latitude" [longitude]="address.longitude"></my-map>

PS: Other functions such as addCircle and addPolyline have the same issue.

@leocaseiro
Copy link
Contributor Author

Thanks for that @DomGaud. Ir worked for me.

dapriett added a commit that referenced this issue Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant