wikipoints/public/map.htm

165 lines
4.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="/js/jquery-ui.js" type="text/javascript"></script>
<script src="//api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="/css/jquery-ui.css" />
<script type="text/javascript">
$(function () {
$("#dialog").dialog(
{
autoOpen: false,
width: 600,
modal: true,
show: {
effect: "blind",
duration: 500
},
hide: {
effect: "explode",
duration: 500
},
buttons: {
"Добавить точку": function () {
addNewPoint();
$(this).dialog("close");
},
"Закрыть": function () {
$(this).dialog("close");
}
}
});
});
function addNewPoint() {
// alert($('#currentLat').val() + ' / ' + $('#currentLng').val());
var responsQuerry = {
name: $('#name').val(),
img: $('#img').val(),
description: $('#description').val(),
source: $('#source').val(),
categoryId: $('#categoryId').val(),
lat: $('#currentLat').val(),
lng: $('#currentLng').val()
}
// /json/categories / addpoint
$.ajax({
type: 'POST',
url: "/json/addpoint",
data: responsQuerry,
dataType: 'json',
success: function (data) {
//alert('ok' + data);
//curentObj.Id = data;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Ошибка - " + XMLHttpRequest.responseText);
}
});
}
function openAddDlg() {
myMap.balloon.close();
$('#dialog').dialog('open');
}
var myMap;
// Дождёмся загрузки API и готовности DOM.
ymaps.ready(init);
function init() {
myMap = new ymaps.Map('map', {
center: [59.694970863, 29.341192627], // СПБ
zoom: 10
});
myMap.events.add('contextmenu', function (e) {
if (!myMap.balloon.isOpen()) {
var coords = e.get('coordPosition');
$('#currentLat').val(coords[0].toPrecision(6));
$('#currentLng').val(coords[1].toPrecision(6));
myMap.balloon.open(coords, {
contentHeader: '',
contentBody: '<div onclick="openAddDlg();" style="cursor:pointer;"> Добавить точку </div>' +
'<div style="cursor:pointer;"> F1 </div>' +
'<div style="cursor:pointer;"> F2 </div>' +
'<div style="cursor:pointer;"> F3 </div>',
contentFooter: '<sup>Координаты точки:' + [
coords[0].toPrecision(6),
coords[1].toPrecision(6)
].join(', ') + '</sup>'
});
}
else {
myMap.balloon.close();
}
});
}
</script>
</head>
<body>
<div id="map" style="width:100%; height:1000px"></div>
<input type="hidden" id="currentLat" name="currentLat">
<input type="hidden" id="currentLng" name="currentLng">
<div id="dialog" title="Добавить точку">
<p>
Название:<br>
<input type="text" id="name" name="name" style="width:100%;"></p>
<p>
Тип:<br>
<select id="categoryId" name="categoryId" style="width:100%;">
<option value="1">Парки и сады</option>
<option value="2">Замки и усадьбы</option>
</select></p>
<p>
URL изображения:<br>
<input type="text" id="img" name="img" style="width:100%;"></p>
<p>
Описание:<br>
<textarea id="description" name="description" style="width:100%;"></textarea></p>
<p>
Источник:<br>
<input type="text" id="source" name="source" style="width:100%;"></p>
</div>
</body>
</html>