diff --git a/public/js/main.js b/public/js/main.js index d233500..8315c1f 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -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 = '
' + + '' + '

' + data.name + '

' + + '
' + '' + '
' points[id].properties.set('balloonContent', description); + + point = getURLParameter('point'); + if (point != null && id == point) + { + myMap.setCenter(points[point].geometry.getCoordinates()); + points[point].balloon.open(); + } } }); }