Заголовок точки теперь ссылка на эту точку.
This commit is contained in:
parent
bb6c9238dd
commit
55faabb709
|
|
@ -9,6 +9,16 @@ var points = Array();
|
|||
var im;
|
||||
var search;
|
||||
|
||||
// -------------------------------- Libs ---------------------------------------
|
||||
|
||||
function getURLParameter(name) {
|
||||
return decodeURI(
|
||||
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function init() {
|
||||
myMap = new ymaps.Map("map", {
|
||||
center: [ymaps.geolocation.latitude, ymaps.geolocation.longitude],
|
||||
|
|
@ -85,6 +95,11 @@ function getPoints()
|
|||
for(var k in data) {
|
||||
myMap.geoObjects.add(constructPoint(data[k]));
|
||||
}
|
||||
|
||||
if (getURLParameter('point') != null)
|
||||
{
|
||||
showInfo(getURLParameter('point'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -100,7 +115,9 @@ function showInfo(id)
|
|||
url: "/json/point/id/" + id,
|
||||
success: function(data) {
|
||||
description = '<div class="infoCard">' +
|
||||
'<a href="/?point='+id+'">' +
|
||||
'<h3>' + data.name + '</h3>' +
|
||||
'</a>' +
|
||||
'<img src="' + data.img + '" />' +
|
||||
'<button type="button" class="btn btn-default btn-xs" onclick="addToRoute(' + id + ')">' +
|
||||
'<span class="glyphicon glyphicon-plus"></span> Добавить в маршрут' +
|
||||
|
|
@ -108,6 +125,13 @@ function showInfo(id)
|
|||
data.description +
|
||||
' <a href="' + data.source + '" target="blank">Подробнее...</a></div>'
|
||||
points[id].properties.set('balloonContent', description);
|
||||
|
||||
point = getURLParameter('point');
|
||||
if (point != null && id == point)
|
||||
{
|
||||
myMap.setCenter(points[point].geometry.getCoordinates());
|
||||
points[point].balloon.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue