﻿var MapLinkX = 0;
var MapLinkY = 0;

function MapLinkMapXY() {
    $("MouseRightClickDiv").style.top = "-900px"; //清除右键菜单
    EndGps();//关掉GPS
    gMap.getmappos_start("MapLink", "地图链接", false, MapLinkOpen, null);
}

function MapLinkOpen(type, MapX, MapY) {
    MapLinkX = MapX;
    MapLinkY = MapY;
    $("MapLinkDiv").style.top = event.clientY+ "px";
    $("MapLinkDiv").style.left = (event.clientX-90) + "px";
    AddMapLinkInfo($("MapLinkInfo"));
}

function AddMapLinkInfo(obj) {
    var MapInfo = escape(obj.value);
    if (obj.value == "") {
        $("MapLinkURL").value = "http://" + location.host + "/mini.aspx?tip@2|" + gMap.getZoom() + "|" + MapLinkX + "|" + MapLinkY + "&ver=2";
        $("MapLinkHTML").value = '<iframe width="480px" height="280px" frameborder="0" scrolling="no" src="' + "http://" + location.host + '/mini.aspx?tip@2|' + gMap.getZoom() + '|' + MapLinkX + "|" + MapLinkY + '&ver=2" marginheight="0" marginwidth="0"></iframe><br /><a href="http://"' + location.host + '/mini.aspx?tip@2|' + gMap.getZoom() + '|' + MapLinkX + "|" + MapLinkY + '&ver=2" target="_blank" style="color:#00f;text-align:left;font-size:12px;">查看大图</a>';
    } else {
    $("MapLinkURL").value = "http://" + location.host + "/mini.aspx?tip@2|" + gMap.getZoom() + "|" + MapLinkX + "|" + MapLinkY + "|" + MapInfo + "&ver=2";
    $("MapLinkHTML").value = '<iframe width="480px" height="280px" frameborder="0" scrolling="no" src="' + "http://" + location.host + '/mini.aspx?tip@2|' + gMap.getZoom() + '|' + MapLinkX + "|" + MapLinkY + "|" + MapInfo + '&ver=2" marginheight="0" marginwidth="0"></iframe><br /><a href="http://"' + location.host + '/mini.aspx?tip@2|' + gMap.getZoom() + '|' + MapLinkX + "|" + MapLinkY + "|" + MapInfo + '&ver=2" target="_blank" style="color:#00f;text-align:left;font-size:12px;">查看大图</a>';
    }
    // $("MapLinkImgButton").value = '<a href="http://' + location.host + '/mini.aspx?img=' + MapLinkX + "|" + MapLinkY + '&ver=2" target="_blank"><img src="http://' + location.host + '/citycomeSkin/global/maplocate.gif" style="width: 61px; height: 16px; border: 0px;" alt="" /></a>';
    $("MapLinkImgButton").value = "2|" + gMap.getZoom() + "|" + MapLinkX + "|" + MapLinkY + "|" + MapInfo + "&ver=2";
}

function MapLinkEnd() {
    $("MapLinkDiv").style.top = "-900px";
    $("MapLinkInfo").value = "";
}



// 右键菜单
$('dSysMap').addEvent('mouseup', function(event) {
    if (event.rightClick) {
        $("MouseRightClickDiv").style.top = event.page.y + "px";
        $("MouseRightClickDiv").style.left = event.page.x + "px";
        return false;
    }
    else {
        $("MouseRightClickDiv").style.top = "-900px"; //移除右键菜单
    }
});


//右键菜单-公交起点设置

function MapCarXY(type) {
    $("MouseRightClickDiv").style.top = "-900px"; //移除右键菜单
    BusSvc.setPoint(type);
}