Answer the question
In order to leave comments, you need to log in
How to connect and use yandex maps in angular?
The project is based on Angular, you need to use yandex maps on it. Packages with npm are not suitable, I need to work with regions and clusters and other things that the yandex maps api gives.
here is an example of how I connect and try to use
in the index.html file I load their library
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
import {Component, OnInit} from "@angular/core";
declare var ymaps:any;
@Component({
selector:'app-map',
templateUrl:'./map.component.html'
})
export class MapComponent implements OnInit{
public map :any;
ngOnInit(){
this.map = new ymaps.Map("map", {
center: [55.76, 37.64],
zoom: 7
});
}
Answer the question
In order to leave comments, you need to log in
ngOnInit() {
ymaps.ready().then(() => {
this.map = new ymaps.Map('map', {
center: [50.450100, 30.523400],
zoom: 12
});
});
}
The logic of working with Yandex.maps in Angular "without a component" is exactly the same as working with Yandex.maps "without Angular" (in plain html).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question