Answer the question
In order to leave comments, you need to log in
How to correctly insert several GeoObjects into a Yandex map?
Good afternoon, I
followed the documentation, Placemark normally gets into the map, but GeoObject does not get up (
var lat = <?php echo $lat;?>,
lon = <?php echo $lon;?>;
ymaps.ready(init);
var myMap, myPlacemark;
function init()
{
myMap = new ymaps.Map("map",
{
center: [lat, lon],
zoom: 15
});
myPlacemark = new ymaps.Placemark([lat,lon],
{
hintContent: '<?php echo $region['country'];?> | <?php echo $region['city'];?>',
// надпись снизу
balloonContent: 'Вы на карте'
});
// myMap.geoObjects.add(myPlacemark); // Если раскоментить, то метка отображается.
// Тут проблемка
// новый геообъект
var myGeoObject = new ymaps.GeoObject(
{
type: 'Point',
coordinates: [lat, lon] // 55.8, 37.8 // 43.25063225, 76.93755332
});
myMap.geoObjects.add(myGeoObject); // не вставляется
}
Answer the question
In order to leave comments, you need to log in
For a GeoObject, the coordinates and type are described inside the geometry property
var myGeoObject = new ymaps.GeoObject({
geometry: {
type: 'Point',
coordinates: [lat, lon] // 55.8, 37.8 // 43.25063225, 76.93755332
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question