Заголовок точки теперь ссылка на эту точку.

This commit is contained in:
Krivchikov Dmitry 2014-04-26 20:07:06 +04:00
parent bb6c9238dd
commit 55faabb709
1 changed files with 24 additions and 0 deletions

View File

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