I'm using angular2-google-maps https://angular-maps.com/ to build a google map with markers. What I'm trying to achieve is creating a marker which is customised with an users social media profile pic. I am going to use this: JS Maps v3: custom marker with user profile picture
To do this, i need to modify the marker code which i cannot access.
Template:
<sebm-google-map-marker
[latitude]="lat"
[longitude]="lon"
[appSocialMediaGoogleMapMarker]="'assets/img/temp/profile-image.png'"
>
</sebm-google-map-marker>
directive.ts
import { Directive, ElementRef, Input } from '@angular/core';
import { GoogleMapsAPIWrapper, MarkerManager, SebmGoogleMapMarker } from 'angular2-google-maps/core';
@Directive({
selector: '[appSocialMediaGoogleMapMarker]'
})
export class SocialMediaGoogleMapMarkerDirective {
@Input('appSocialMediaGoogleMapMarker') socialMediaImage: string;
constructor(
el: ElementRef,
private gmapsApi: GoogleMapsAPIWrapper,
private markerManager: MarkerManager
) {
this.gmapsApi.getNativeMap().then(map => {
this.markerManager.getNativeMarker(el.nativeElement).then(marker => {
});
});
console.log(this.socialMediaImage);
}
}
The error i'm getting is
Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
which is occuring on this line:
this.markerManager.getNativeMarker(el.nativeElement).then(marker => {
Also this.socialMediaImage
if undefined.
Any help would be great, thanks.
`. I'll add a message when I have created a plunkr.
– Gavin Bruce Apr 12 '17 at 12:49