TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
275.3k
How to assign value of latitude and langtide google map on e
Dec 27 2019 3:17 PM
problem
I need to assign value of latitude and langtide on event ngOnInit ?
I work on angular 7
I assign value of latitude and alngtude on ngoninit but not work
ngOnInit() {
this.lat = value
this.lng= value
}
so How to assign values of lng and lat on event ngoninit and display google map
based on values assigned on ngoninit event
import
{ Component, AfterViewInit, ViewChild, ElementRef } from
'@angular/core'
;
@Component({
selector:
'app-root'
,
templateUrl:
'./app.component.html'
,
styleUrls: [
'./app.component.css'
]
})
export
class
AppComponent
implements
AfterViewInit {
title =
'angular-gmap'
;
@ViewChild(
'mapContainer'
, {
static
:
false
}) gmap: ElementRef;
map: google.maps.Map;
lat = 40.73061;
lng = -73.935242;
coordinates =
new
google.maps.LatLng(
this
.lat,
this
.lng);
mapOptions: google.maps.MapOptions = {
center:
this
.coordinates,
zoom: 8
};
marker =
new
google.maps.Marker({
position:
this
.coordinates,
map:
this
.map,
title:
'Hello World!'
});
ngOnInit() {
//here i need to assign values of lat and lng and display map based on these values
console.log(
"Hi man"
);
}
ngAfterViewInit() {
console.log(
"Hi women"
);
this
.mapInitializer();
}
mapInitializer() {
this
.map =
new
google.maps.Map(
this
.gmap.nativeElement,
this
.mapOptions);
this
.marker.setMap(
this
.map);
}
}
Reply
Answers (
1
)
How to get id from list when text input match or equal items
How to return value of Loc value from url angular 7 ?