- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
[...]
YMaps.Events.observe(map, map.Events.Click, function (map, mEvent) {
if (ymap_canmark) {
var newtip = mapAddTip('Новая метка', '');
newtip.setGeoPoint(mEvent.getGeoPoint());
newtip.openBalloon();
newtip.closeBalloon();
}
}, map);
[...]
function mapAddTip(head, body) {
var olay = new YMaps.Placemark(map.getCenter(), {draggable: true});
olay.isfirstlaunch = 1;
tip_links++;
olay.edlink = tip_links;
tip_dbids++;
olay.dbid = tip_dbids;
olay.setBalloonContent("<div id='hdr-"+tip_links+"' style='font-weight:bold;'>"+head+"</div><div id='txt-"+tip_links+"'>"+
body+"</div><!--<div id='edit-link-"+tip_links+"'><br>[ <a href='#'>Редактировать</a> ]</div>-->");
olay.setIconContent(head);
YMaps.Events.observe(olay, olay.Events.BalloonOpen, function () {
if (olay.isfirstlaunch > 0) {
YMaps.jQuery('#edit-link-' + olay.edlink).bind('click', function() { EditTip(olay, this) });
if (olay.isfirstlaunch == 1) { dbAddTip(olay); }
olay.isfirstlaunch = 0;
}}, map);
YMaps.Events.observe(olay, olay.Events.BalloonClose, function () {
olay.setIconContent(GetTipHead(olay));
}, map);
YMaps.Events.observe(olay, olay.Events.DragStart, function () {
var ddiv = document.createElement('div');
ddiv.style.position = 'absolute';
var pel = document.getElementById('ui-view');
ddiv.style.left = parseInt(pel.style.left) + parseInt(pel.style.width) - 235;
ddiv.style.top = pel.offsetTop+5;
ddiv.style.zIndex = '10000001';
ddiv.style.padding = '0px';
ddiv.style.margin = '0px';
ddiv.style.color = 'gray';
ddiv.style.fontSize = '10px';
ddiv.setAttribute('id', 'drag-coords');
document.body.appendChild(ddiv);
}, map);
YMaps.Events.observe(olay, olay.Events.Drag, function () {
YMaps.jQuery('#drag-coords').html('x='+olay.getGeoPoint().getX()+'; y='+olay.getGeoPoint().getY());
}, map);
YMaps.Events.observe(olay, olay.Events.DragEnd, function () {
YMaps.jQuery('#drag-coords').remove();
if (olay.isfirstlaunch != 1) { olay.openBalloon(); dbSaveTip(olay); olay.closeBalloon(); }
}, map);
map.addOverlay(olay);
return olay;
}
function dbAddTip(tip) { /* [...] */
try {
var test = document.getElementById("m_id");
test.setAttribute("test", "success");
if (test.getAttribute("test") == "success") {
try {
var t_id = document.getElementById("m_id").value;
var t_x = tip.getGeoPoint().getX();
var t_y = tip.getGeoPoint().getY();
var t_head = GetTipHead(tip);
var t_body = GetTipBody(tip);
var XmlHttp = newXmlHttp();
XmlHttp.open("GET", maps_cgi+"?tip=new"+t_id+"&x="+t_x+"&y="+t_y+"&head="+t_head+"&body="+t_body, false);
XmlHttp.send(null);
test.parentNode.removeChild(test);
} catch (e) {}
}
} catch (e) { }
}
function GetTipBody(tip) { return YMaps.jQuery('#txt-'+tip.edlink).html(); }
function GetTipHead(tip) { return YMaps.jQuery('#hdr-'+tip.edlink).html(); }
function dbSaveTip(tip) {
/*
[...]
*/
}
Почти шедевральне :D http://www.virtual.donetsk.ua/serv/maps.js