S
S
sasasa_742014-04-07 13:24:38
JavaScript
sasasa_74, 2014-04-07 13:24:38

2gis API - How, knowing the latitude and longitude of the marker, show it on the map

There is a map, a marker has been added to it
Link

<a href="#" onclick="Click(61.396344,55.190962,18)">Ссылка 1</a>

it is necessary to somehow implement that by clicking on the link it would show this marker, which is located at the specified coordinates

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
enchikiben, 2014-04-07
@EnChikiben

function Click(longitude, latitude, accuracy) {
  var myMap;
  DG.autoload(function () {
    // Инициализируем карту, устанавливаем её центр и масштаб:
    myMap = new DG.Map('map');
    myMap.setCenter(new DG.GeoPoint(82.967, 55.008), 11);
    
    // Добавляем элемент управления коэффициентом масштабирования:
    myMap.controls.add(new DG.Controls.Zoom());
  });

  // Установка центра карты текущего местоположени:
  myMap.setCenter(new DG.GeoPoint(longitude, latitude));
  // Установка максимального зума:
  myMap.setZoom(myMap.getMaxZoom());

  // Создаем маркер с картинкой по умолчанию:
  var marker = new DG.Markers.Common({geoPoint:new DG.GeoPoint(longitude, latitude) });
  // Добавим маркер на карту:
  myMap.markers.add(marker);
}

something like a memory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question