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
Does not load sebm-google-map-marker with *ngFor | async #330
Comments
please any update on above issue? |
hey @krunal039 - can you check if the |
Hi Sebastian, i just updated my angular2 to latest and it has solved issue not sure it was my bad code or something with angular. but it's fixed. is there also options to set zoom auto based on all marker? |
@krunal039 no, not possible right now - sorry. please open a new issue for this if you need this. so we can discuss the api details. thanks! |
@SebastianM
|
I`m facing the same issue using angular.rc4. |
@SebastionM I'm having the same issue on rc4. Markers are not showing up on the map. The markers are showing on the dom though |
same issue here. any solutions? |
same issue here too. on angular rc3 |
Finally figure it out. This is how i figured it out:
this.observable = this.gisDataService.getEntities(dcode);
this.data.forEach(element => { Note: I figured it out that when data is received in JSON it is not getting converted to number even if you map JSON to a class(as I did). But at the time of Pushing (in pushMarker() function you have to explicitly convert lat/lng to Number(). Hope it helps. |
@nileshmahant Super! I needed to explicitly convert to Number(). Thank you :) |
Thanks @nileshmahant solved my problem! |
I would like to re-open this one, to get the conversion in the component, instead of having to feed it the converted value |
+1 for me, took me a while to figure this out and the use-case for loading markers from JSON is a pretty logical one |
I just ran into this and thought I would share my work around in case anyone else runs into it. In my ts file I added a simple method to convert a string to a number:
Then in the html I just pass in the lat/long to this method:
|
Nice!
May I suggest that instead of a private function, why not create a pipe to
do this. It would look much nicer looking and portable.
Also not much more work.
I could provide an example if you want one :-)
…On 1 April 2017 at 02:12, Austin LaRue ***@***.***> wrote:
I just ran into this and thought I would share my work around in case
anyone else runs into it.
In my ts file I added a simple method to convert a string to a number:
private convertStringToNumber(value: string): number {
return +value;
}
Then in the html I just pass in the lat/long to this method:
<sebm-google-map-marker *ngFor="let location of clientLocations"
[latitude]="convertStringToNumber(location.latitude)" [longitude]="
convertStringToNumber(location.longitude)"></sebm-google-map-marker>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#330 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AY4FmON0vwkqtvbC3qlBK1E6SQQQsAr2ks5rrSXggaJpZM4IaCkp>
.
|
Wow I was beating my head against this for over an hour before I found this issue. This worked perfectly for me:) |
In general, my experience is that if agm-markers are visible in DOM but not shown, you probably supplied a wrong object type to ngFor in some way (either improper type as Number type mentioned above or something not containing lat and long at all which was my case). Double check what you are sending to markers array. |
I would like to reopen this issue again.
and to add and display the markers in my service.ts file, I have
|
I too was saving the
Official Doc: https://angular.io/api/common/DecimalPipe |
I have service for async data to load from json file. *ngFor does create sebm-google-map-marker for all data returened but sebm-google-map does not load newly added marker.
marker.json
{ "data" : [ { "lat": 51.673858, "lng": 7.815982, "label": "A", "draggable": true }, { "lat": 51.373858, "lng": 7.215982, "label": "B", "draggable": false }, { "lat": 51.723858, "lng": 7.895982, "label": "C", "draggable": true } ] }
service.ts
getmockStores() { return this._http.get(CONFIG.baseUrls.mockstoreSelector) .map((response: Response) => <marker[]>response.json().data) .catch(this._exceptionService.catchBadResponse) }
component.ts
` getMockMarkers(){
})
}`
.component.html
<sebm-google-map [latitude]="lat" [longitude]="lng" [zoom]="zoom" [disableDefaultUI]="false"> <sebm-google-map-marker *ngFor="#m of mockStores" [latitude]="m.lat" [longitude]="m.lng" [label]="m.label" [markerDraggable]="m.draggable" (dragEnd)="markerDragEnd(m, $event)"> </sebm-google-map-marker> </sebm-google-map>
The text was updated successfully, but these errors were encountered: