google 地图

先暂且记录,以后有时间慢慢调整注释

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script>  //谷歌地图JS
    <script src="JS/mapn/jquery.js" type="text/javascript"></script>//JQUERY1.9
   
    <script src="JS/mapn/markerclusterer.js" type="text/javascript"></script>//marker点汇集
    <script src="JS/mapn/common.js" type="text/javascript"></script>
    <link href="Theme/map/styles/style.css" rel="stylesheet" type="text/css" /> <link href="/js-content-select/page-webWin.css" rel="stylesheet" type="text/css" />
    <script src="/js-content-select/page-webWin.js" type="text/javascript"></script>
    <script src="JS/mapn/mapmanage.js" type="text/javascript"></script>//地图管理JS
   <script src="JS/mapn/mapdata.js" type="text/javascript"></script>//地图数据


mapmanage.JS


var mapcontrol = {};
mapcontrol.map = null;
mapcontrol.markerClusterer = null;
mapcontrol.markers = [];
mapcontrol.infoWindow = null;
mapcontrol.data = null;
mapcontrol.leftdata = [];
mapcontrol.panorama = null;
mapcontrol.isMapReload = true;
mapcontrol.isMarkerReload = true;
mapcontrol.geocoder = null;
mapcontrol.locationMarker = null;
mapcontrol.nearMarker = null;


mapcontrol.init = function (data) {
    mapcontrol.data = data.data;
    mapcontrol.leftdata = data.data;

    loadleft(mapcontrol.leftdata, 1);

    if (mapcontrol.isMapReload) {
        var latlng = new google.maps.LatLng(43.762, -79.412);
        var options = {
            'zoom': 11,
            'center': latlng,
            'mapTypeId': google.maps.MapTypeId.ROADMAP
        };
        mapcontrol.geocoder = new google.maps.Geocoder();
        mapcontrol.map = new google.maps.Map($('#googleMap')[0], options);


        google.maps.event.addListener(mapcontrol.map, 'zoom_changed', function () {
            var zoomIndex = mapcontrol.map.getZoom();
            if (zoomIndex == 21) {
                mapcontrol.markerClusterer.styles_[0].url = "Theme/map/images/map/0.png";
                mapcontrol.markerClusterer.styles_[1].url = "Theme/map/images/map/0.png";
                mapcontrol.markerClusterer.styles_[2].url = "Theme/map/images/map/0.png";
            } else {
                mapcontrol.markerClusterer.styles_[0].url = "Theme/map/images/map/m1.png";
                mapcontrol.markerClusterer.styles_[1].url = "Theme/map/images/map/m2.png";
                mapcontrol.markerClusterer.styles_[2].url = "Theme/map/images/map/m3.png";
            }
            mapcontrol.leftReload();
        });
        google.maps.event.addListener(mapcontrol.map, 'bounds_changed', function () {
            mapcontrol.leftReload();
        });
        google.maps.event.addListener(mapcontrol.map, 'dragend', function () {
            mapcontrol.leftReload();
        });

        mapcontrol.infoWindow = new google.maps.InfoWindow({ pixelOffset: { height: -25, width: 0} });

        google.maps.event.addListener(mapcontrol.infoWindow, 'closeclick', function () {
            mapcontrol.closeLocationMarker();
        });


    }
    if (mapcontrol.isMarkerReload) {
        mapcontrol.showMarkers();
    }

};

mapcontrol.showMarkers = function () {
    mapcontrol.markers = [];

    if (mapcontrol.markerClusterer) {
        mapcontrol.markerClusterer.clearMarkers();
    }

    for (var i = 0; i < mapcontrol.data.length; i++) {
        //mapcontrol.leftdata[i].rownum = i + 1;
        var latLng = new google.maps.LatLng(mapcontrol.data[i].lat,
        mapcontrol.data[i].lng);

        var imageUrl = mapcontrol.data[i].icon;
        var marker = new google.maps.Marker({
            'position': latLng,
            'icon': imageUrl,
            'zIndex': 1
        });

        var fn = mapcontrol.markerClickFunction(mapcontrol.data[i], latLng);
        google.maps.event.addListener(marker, 'click', fn);

        mapcontrol.markers.push(marker);
    }

    mapcontrol.markerClusterer = new MarkerClusterer(mapcontrol.map, mapcontrol.markers, { imagePath: 'Theme/map/images/map/m'});
    google.maps.event.addListener(mapcontrol.markerClusterer, 'clusterclick', function () {
        var zoomIndex = mapcontrol.map.getZoom();
         if (zoomIndex == 21) {
            var clusterer = mapcontrol.markerClusterer.clusters_[0].markers_[0];
            var position = clusterer.position;
            var data = mapcontrol.getDataByClusterer(position);
            var infoHtml = mapcontrol.getInfoHtml(data[0]);
            mapcontrol.openInfoWindow(infoHtml, data[1]);
        }
        mapcontrol.leftReload();
    });
};

mapcontrol.getDataByClusterer = function (position) {
    var clustererData = [], latlng, infodata = [];
    $.each(mapcontrol.leftdata, function (i, data) {
        var point = new google.maps.LatLng(data.lat, data.lng);
        if (position.equals(point)) {
            latlng = point;
            clustererData.push(mapcontrol.leftdata[i]);
        }
    });
    infodata.push(clustererData);
    infodata.push(latlng);
    return infodata;
}

mapcontrol.showNearMarkers = function (latLng) {
    if (mapcontrol.nearMarker) mapcontrol.nearMarker.setMap(null);
    mapcontrol.nearMarker = new google.maps.Marker({
        'position': latLng,
        'map': mapcontrol.map,
        'zIndex': 3,
        'title':'我在这里'
    });
}

mapcontrol.closeNearMarkers = function () {
    if (mapcontrol.nearMarker) mapcontrol.nearMarker.setMap(null);
}

mapcontrol.showLocationMarker = function (latLng) {
    if (mapcontrol.locationMarker) mapcontrol.locationMarker.setMap(null);
    mapcontrol.locationMarker = new google.maps.Marker({
        'position': latLng,            
        'draggable': true,
        'map': mapcontrol.map,
        'zIndex':3
    });
}

mapcontrol.closeLocationMarker = function () {
    if (mapcontrol.locationMarker) mapcontrol.locationMarker.setMap(null);
}


mapcontrol.addLeftEvent = function (data, fn) {
    var title = [];
    var item_title = document.createElement('A');
    item_title.href = 'javascript:void(0);';
    item_title.className = 'list-name';
    item_title.innerHTML = data.itemsname;
    var item_detail = document.createElement('A');
    item_detail.href = data.url + "/shop/" + data.itemid + ".aspx";
    item_detail.target = "_blank";
    item_detail.className = 'detail';
    item_detail.innerHTML = "[详情]";
    title.push(item_title);
    title.push(item_detail);


    var latLng = new google.maps.LatLng(data.lat, data.lng);
    if (!fn) fn = mapcontrol.markerClickFunction(data, latLng);

    google.maps.event.addDomListener(item_title, 'click', fn);

    return title;
}



mapcontrol.markerClickFunction = function (data, latlng) {
    return function (e) {
        e.cancelBubble = true;
        e.returnValue = false;
        if (e.stopPropagation) {
            e.stopPropagation();
            e.preventDefault();
        }
        var clustererData = [];
        $.each(mapcontrol.leftdata, function (i, data) {
            var point = new google.maps.LatLng(data.lat, data.lng);
            if (latlng.equals(point)) {
                clustererData.push(mapcontrol.leftdata[i]);
            }
        });
        var infoHtml = mapcontrol.getInfoHtml(clustererData);
        mapcontrol.openInfoWindow(infoHtml, latlng);
    };
};

mapcontrol.openInfoWindow = function (infoHtml, latlng) {
    if (!infoHtml || !latlng) return;
    //var infoHtml = mapcontrol.getInfoHtml(data);

    mapcontrol.infoWindow.setContent(infoHtml);
    mapcontrol.infoWindow.setPosition(latlng);
    mapcontrol.infoWindow.open(mapcontrol.map);
}

mapcontrol.closeInfoWindow = function () {
    if (mapcontrol.infoWindow) mapcontrol.infoWindow.close();
}



mapcontrol.leftReload = function () {
    var bounds =mapcontrol.map.getBounds();
    mapcontrol.leftdata = [];
    $.each(mapcontrol.data, function (i, data) {
        var point = new google.maps.LatLng(data.lat, data.lng);
        if (bounds.contains(point)) {
            mapcontrol.leftdata.push(data);
        }
    });
    loadleft(mapcontrol.leftdata, 1);
}


mapcontrol.getInfoHtml = function (data) {

    var array = [];
    if (!data.length) array.push(data); else array = data;
    var height = "200px;";
    if (array.length >= 2) height = "400px";
    var inhtml = '<div style="height:'+height+';">';
    for (var i = 0; i < array.length; i++) {
        inhtml += '<table style=" height:200px;">';
        inhtml += '  <tr>';
        inhtml += '  <td rowspan="5"><a href="javascript:void(0);"> <img src="' + array[i].logo + '" /> </a></td>';
        inhtml += '  <td rowspan="5">' + array[i].rownum + '</td>';
        inhtml += '   <td><a href="' + array[i].url + '/shop/' + array[i].itemid + '.aspx" target="_blank">' + array[i].itemsname + ' </a> <a href="#" class="detail"> ' + array[i].subcategoryname + ' </a></td>';
        inhtml += '   </tr>';
        inhtml += '    <tr>';
        inhtml += '   <td><p class="staricon"><em style="width:' + parseInt(array[i].starnum) * 20 + '%"> </em><span></span></p></td>';
        inhtml += '   </tr>';
        inhtml += '    <tr>';
        inhtml += '  <td><a href="javascript:void(0);"> ' + array[i].street + array[i].areaname + " " + array[i].postcode + ' </a></td>';
        inhtml += '  </tr>';
        inhtml += '   <tr>';
        inhtml += '  <td>' + data.tel + '</td>';
        inhtml += '  </tr>';
        inhtml += '    <tr>';
        inhtml += '   <td> <a href="javascript:void(0);" class="icon01" οnclick="favBusiness(' + array[i].itemid + ',\'' + array[i].from + '\')"> 收藏 </a> <a target="_blank" href="https://maps.google.com/maps?daddr=' + data.street + '" class="icon04"> 获取路线 </a> <a href="javascript:void(0);" class="icon02 street" lat="' + array[i].lat + '" lng="' + array[i].lng + '" οnclick="showStreet(' + array[i].lat + ',' + array[i].lng + ')"> 街景 </a> <a href="javascript:void(0);" class="icon03" οnclick="___show_error()"> 纠错 </a></td>';
        inhtml += '   </tr>';
        inhtml += '</table>';


        //        inhtml += '<div class="layter">';
        //        inhtml += ' <div class="listbox"> <span class="list-dd-pic fl"> <a href="javascript:void(0);"> <img src="' + array[i].logo+ '" /> </a></span>';
        //        inhtml += '<dl class="list-dl">';
        //        inhtml += '  <dt class="list-dl-icon"> ' + array[i].rownum + ' </dt>';
        //        inhtml += '  <dd class="list-dd-cont">';
        //        inhtml += '    <div class="list-dd-top">';
        //        inhtml += '      <ul>';
        //        inhtml += '       <li class="list-dd-name"> <a href="' + array[i].url + '/shop/' + array[i].itemid + '.aspx" target="_blank">' + array[i].itemsname + ' </a> <a href="#" class="detail"> ' + array[i].subcategoryname + ' </a> </li>';
        //        if (array[i].from == "eat") {
        //            
        //            inhtml += '       <li class="list-dd-mesg"> <p class="staricon"><em style="width:' + parseInt(array[i].starnum) * 20 + '%"> </em><span></span></p> </li>';
        //        } 
        //        inhtml += '       <li class="list-dd-phone"> ' + array[i].tel + ' </li>';
        //        inhtml += '     </ul>';
        //        inhtml += '   </div>';
        //        inhtml += '   <div class="list-dd-bottom">';
        //        inhtml += '     <ul>';
        //        inhtml += '       <li class="address"> <a href="javascript:void(0);"> ' + array[i].street + array[i].areaname + " " + array[i].postcode + ' </a> </li>';
        //        inhtml += '       <li>';
        //        inhtml += '         <div class="operate"> <a href="javascript:void(0);" class="icon01" οnclick="favBusiness(' + array[i].itemid + ',\'' + array[i].from + '\')"> 收藏 </a> <a target="_blank" href="https://maps.google.com/maps?daddr=' + array[i].street + '" class="icon04"> 获取路线 </a> <a href="javascript:void(0);" class="icon02 street" lat="' + array[i].lat + '" lng="' + array[i].lng + '" οnclick="showStreet(' + array[i].lat + ',' + array[i].lng + ')"> 街景 </a> <a href="javascript:void(0);" class="icon03" οnclick="___show_error()"> 纠错 </a> </div>';
        //        inhtml += '       </li>';
        //        inhtml += '     </ul>';
        //        inhtml += '   </div>';
        //        inhtml += ' </dd>';
        //        inhtml += ' </dl>';
        //        inhtml += '</div>';
        //        inhtml += '</div>';
    }
    inhtml += '</div>';
    return inhtml;
}


mapdata.JS



var pagesize = 10, pageindex = 1;
var YPURL = 'http://yellowpage.yorkbbs.ca', EATURL = 'http://eat.yorkbbs.ca';
var url = document.referrer;
geturlparam(url);
var from = url.indexOf("yp.yorkbbs.ca") > 0 ? "yp" : "eat";
var docwidth;
var docheight;
$(function () {
    //初始化数据
    $("#hdnfrom").val(from);
    businessBind();
    categoryBind();
    areaBind();
    addressBind();

    docwidth = getDocWidth();
    docheight = getDocHeight();
    var width = docwidth - $('.listbox').width(), height = docheight - 120;
    $("#googleMap").css({ "width": width - 3, "height": height });
    $(".listbox").css({ "height": docheight - 275 });

    $(window).resize(function () {
        if ($("#hdnisstreet").val() == "") {
            docwidth = getDocWidth();
            docheight = getDocHeight();
            var width = docwidth - $('.listbox').width(), height = docheight - 120;
            $("#googleMap").css({ "width": width - 3, "height": height });
            $(".listbox").css({ "height": docheight - 275 });
        }
    });

    $("#leftpage").on("click", ".leftpage", function () {
        pageindex = $(this).attr("id");
        loadleft(mapcontrol.leftdata, pageindex);
    });

    $('#box_link').click(function () {
        $('.left').animate({
            left: "-358"
        }, 500, function () {
            $(".arrow01").show();
        });

        $('#googleMap,#streetview').animate({
            width: '+=358'
        }, 500, function () {
            var map = mapcontrol.map;
            if (map) {
                google.maps.event.trigger(map, 'resize');
            }
        });
    });

    $('.arrow01').click(function () {
        var isstreet = $("#hdnisstreet").val();
        $(".arrow01").hide();
        $('.left').animate({
            left: "0"
        }, 500);
        if (isstreet == "1") {
            $("#hdnisstreet").val("");
            var width = docwidth - $('.left').width(), height = docheight - 120;
            $('#googleMap,#streetview').animate({
                right: "0",
                top: 3,
                width: width - 2,
                height: height
            }, 500);
            if (mapcontrol.panorama)
                mapcontrol.panorama.setVisible(false);
        }
        else {
            $('#googleMap,#streetview').animate({
                width: "-=358"
            }, 500, function () {
                var map = mapcontrol.map;
                if (map) {
                    google.maps.event.trigger(map, 'resize');
                }
            });
        }

    });


    $("#leftdata").on("click", ".street", function () {
        var lat = $(this).attr("lat");
        var lng = $(this).attr("lng");
        showStreet(lat, lng);
    });

    $("#aMyLocation").click(function () {
        var content = '';
        content += '<div class="add_address">';
        content += '<h4><span class="fl">我的位置</span></h4>';
        content += '<ul>';
        content += '  <li> <span>备注</span> <span>';
        content += '    <input type="text" class="exit exit-s" value="如我家,公司" id="remark" οnfοcus="if(this.value==\'如我家,公司\')this.value=\'\'" οnblur="if(this.value==\'\')this.value=\'如我家,公司\'"/>';
        content += '    </span> <span>';
        content += '    <input  type="checkbox" value="" style="margin:6px 0 0 0;" id="isdefault"/>';
        content += '    </span> <span> 设为默认位置</span> </li>';
        content += '  <li> <span>地址</span> <span>';
        content += '    <input type="text" class="exit exit-b" value="#@#"/>';
        content += '    </span> <span>';
        content += '    </span>';
        content += '    <p class="please"> 请输入地址或拖动图标定位 </p>';
        content += '  </li>';
        content += '  <li class="yes">';
        content += '   <input type="button" value="确定" class="li-button" οnclick="addMyAddress()"/>';
        content += '   <input type="button" value="取消"  class="li-button" οnclick="clearAddLocation_Marker()"/>';
        content += '  </li>';
        content += ' </ul>';
        content += '</div>';

        
        var latLng = mapcontrol.map.getCenter();
        mapcontrol.showLocationMarker(latLng);
        geocodePosition(latLng, content);
        google.maps.event.addListener(mapcontrol.locationMarker, 'dragend', function () {
            geocodePosition(mapcontrol.locationMarker.position, content);
        });
    });


    $("#aNearBusiness").click(function () {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(geoSuccess, geoError, {
                timeout: 8000
            });
        }
    });

    $("#category").on("click", ".category", function () {
        var iscategory = $(this).attr("category");
        var clickfrom = $(this).attr("name");
        var from = $("hdnfrom").val();
        if (from != clickfrom) {
            clearsuaixuan();
        }
        $("#selectcategory").html($(this).attr("categoryname"));
        if (iscategory == 1) {
            $("#hdnCategory").val($(this).attr("id"));
            $("#hdnfrom").val($(this).attr("name"));
        } else {
            $("#hdnCategory").val("");
            $("#hdnfrom").val($(this).attr("name"));
            $("#hdnsubcategory").val($(this).attr("id"));
        }
        $(".sx").removeClass("choose");
        mapcontrol.isMapReload = false;
        businessBind();
    });

    $("#btnSearch").click(function () {
        var key = $.trim($("#txtSearch").val());
        if (key == "" || key == "搜索行业、商家、菜名、地址、邮编等等") return;
        $("#hdnkeyword").val(key);
        mapcontrol.isMapReload = false;
        businessBind();
        $("#txtSearch").val("");
        $("#hdnkeyword").val("");
    });

    $("#allCategory,#allArea").click(function () {
        if ($(this).attr("id") == "allCategory") $("#hdnCategory").val("");
        else $("#hdncity").val("");
        mapcontrol.isMapReload = false;
        businessBind();
    });

    $("#area").on("click", ".area", function () {
        $("#hdncity").val($(this).attr("id"));
        $("#selectarea").html($(this).attr("areaname"));
        mapcontrol.isMapReload = false;
        businessBind();
    });

    $(".sortclick").click(function () {
        var id = $(this).attr("id");
        $("#hdnsort").val(id);
        $("#selectsort").html($(this).attr("name"));
        mapcontrol.isMapReload = false;
        businessBind();
    });

    $("#aCommend,#aAuth,#aGoodAppr,#asjlm").click(function () {
        var id = $(this).attr("id");
        $(this).toggleClass("choose");
        clearsuaixuan();
        var param = "";
        $(".choose").each(function () {
            var cid = $(this).attr("id");
            switch (cid) {
                case "aCommend":
                    $("#hdncomment").val("1");
                    break;
                case "aAuth":
                    $("#hdnauth").val("1");
                    break;
                case "aGoodAppr":
                    $("#hdngoodappr").val("1");
                    break;
                case "asjlm":
                    $("#hdnsjlm").val("1");
                    break;
            }
        });
        mapcontrol.isMapReload = false;
        businessBind();
    });

});

function clearsuaixuan() {
    $("#hdncomment").val("");
    $("#hdnauth").val("");
    $("#hdngoodappr").val("");
    $("#hdnsjlm").val("");
}

function geoSuccess(p) {
    var lat = p.coords.latitude;
    var lng = p.coords.longitude;
    var latLng = new google.maps.LatLng(lat, lng);
    $("#hdncity").val("");
    $("#hdnnearlatlng").val(lat + "|" + lng);
    mapcontrol.isMapReload = false;
    mapcontrol.showNearMarkers(latLng);
    businessBind();
}

function geoError(e) {
    switch (e.code) {
        case 1:
            alert("没有权限");
            break;
        case 2:
        case 3:
            var latlng = $("#hdndefaultlatlng").val().split('|');
            if (latlng.length > 1) {
                var atLng = new google.maps.LatLng(latlng[0], latlng[1]);
                $("#hdncity").val("");
                $("#hdnnearlatlng").val(latlng[0] + "|" + latlng[1]);
                mapcontrol.isMapReload = false;
                mapcontrol.showNearMarkers(atLng);
                businessBind();
            } else {
                alert("暂时无法获取你的位置!");
            }
            break;
    }
}

var address_components;
function geocodePosition(latLng, content) {//改变经纬度时获取信息
    mapcontrol.geocoder.geocode({
        latLng: latLng
    }, function (results, state) {
        if (state == google.maps.GeocoderStatus.OK) {
            if (results[0]) {
                address_components = results[0].address_components
                address = results[0].formatted_address;
            }
        }
        if (address) {
            $("#hdnaddresslatlng").val(latLng.k + "|" + latLng.A);
            $("#hdnaddress").val(address);
            content = content.replace("#@#", address);
        } else {
            if (address_components) {
                $("#hdnaddress").val(address_components[3]["short_name"]);
                $("#hdnaddresslatlng").val(latLng.k + "|" + latLng.A);
                content = content.replace("#@#", address_components[3]["short_name"]);
            } else {
                content = content.replace("#@#", "");
            }
        }
        mapcontrol.openInfoWindow(content, latLng);
    });
}

function clearAddLocation_Marker() {
    mapcontrol.closeInfoWindow();
    mapcontrol.closeLocationMarker();

}

function geturlparam(url) {
    var strurl = "";
    if (url.indexOf("yp.yorkbbs.ca/List") > 0) {
        strurl = url.replace("http://yp.yorkbbs.ca/List/", "").replace(".aspx", "");
    } else {
        strurl = url.replace("http://eat.yorkbbs.ca/List/", "").replace(".aspx", "");
    }
    var param = strurl.split("-");
    if (param.length > 0) {
        $("#hdnCategory").val(param[0]);
        if (param.length == 2) {
            $("#hdnsubcategory").val(param[1]);
        }
    }
}



function areaBind() {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=getArea',
        dataType: "html",
        success: function (result) {
            if (result) {
                $("#area").html(result);
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function categoryBind() {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=getCategory',
        dataType: "html",
        success: function (result) {
            if (result) {
                $("#category").html(result);

                if ($("#hdnsubcategory").val() != "") {
                    var name = $("#category").find(".category");
                    name.each(function () {
                        if ($(this).attr("id") == $("#hdnsubcategory").val()) {
                            $("#selectcategory").html($(this).attr("categoryname"));
                        }
                    });
                } else if ($("#hdnCategory").val() != "") {
                    var name = $("#category").find(".category");
                    name.each(function () {
                        if ($(this).attr("id") == $("#hdnCategory").val()) {
                            $("#selectcategory").html($(this).attr("categoryname"));
                        }
                    });
                }
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function favBusiness(id, from) {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=addfav&id=' + id + "&from=" + from,
        dataType: "json",
        success: function (result) {
            result = eval(result);
            if (result.result == "error") {
                alert(result.error_msg);
            } else {
                alert(result.success_msg);
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function addMyAddress() {
    var address = $("#hdnaddress").val();
    if (address.length > 100) alert("地址太长,请重新输入");
    var latlng = $("#hdnaddresslatlng").val();
    var remark = $("#remark").val();
    if (remark.length > 100) alert("备注太长,请重新输入");
    var isdefault = $("#isdefault").is(":checked") ? 1 : 0;
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=addaddress&address=' + address + "&remark=" + remark + "&isdefault=" + isdefault + "&latlng=" + latlng,
        dataType: "json",
        success: function (result) {
            result = eval(result);
            if (result.result == "error") {
                alert(result.error_msg);
            } else {
                clearAddLocation_Marker();
                alert("添加成功!");
                addressBind();
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function addressBind() {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=getaddress',
        dataType: "json",
        success: function (result) {
            if (result.list) {
                result = eval(result.list);
                var inhtml = '';
                for (var i = 0; i < result.length; i++) {
                    inhtml += '<li> <span>' + result[i].udremark + '--' + result[i].udaddress + '</span><i>';
                    if (result[i].udisdefault == "1") {
                        $("#hdndefaultlatlng").val(result[i].udlat + "|" + result[i].udlng);
                        inhtml += '<a href="javascript:void(0);"> 默认位置 </a>';
                    } else {
                        inhtml += ' <a href="javascript:void(0);" οnclick="defaultaddress(' + result[i].udid + ')" class="firsthand"> 设为默认 </a>';
                    }
                    inhtml += ' </i><a href="javascript:void(0);" class="close" οnclick="deladdress(' + result[i].udid + ')"></a> </li>';
                }
                $("#ulmyaddress").html(inhtml);
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function defaultaddress(id) {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=defaultaddress&id=' + id,
        dataType: "json",
        success: function (result) {
            result = eval(result);
            if (result.result == "error") {
                alert(result.error_msg);
            } else {
                addressBind();
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function deladdress(id) {
    $.ajax({
        type: "POST",
        async: true,
        url: 'Handler/map.ashx?method=deladdress&id=' + id,
        dataType: "json",
        success: function (result) {
            result = eval(result);
            if (result.result == "error") {
                alert(result.error_msg);
            } else {
                addressBind();
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}

function businessBind() {
    var category = $("#hdnCategory").val(),
       subcategory = $("#hdnsubcategory").val(),
       city = $("#hdncity").val(),
       comment = $("#hdncomment").val(),
       auth = $("#hdnauth").val(),
       goodappr = $("#hdngoodappr").val(),
       sort = $("#hdnsort").val(),
       from = $("#hdnfrom").val(),
       nearby = $("#hdnnearby").val(),
       sjlm = $("#hdnsjlm").val(),
       keyword = $("#hdnkeyword").val(); ;

    var param = "";
    if (category) param += "&category=" + category;
    if (subcategory) param += "&subcategory=" + subcategory;
    if (city) param += "&city=" + city;
    if (comment) param += "&comment=" + comment;
    if (auth) param += "&auth=" + auth;
    if (goodappr) param += "&goodappr=" + goodappr;
    if (sort) param += "&sort=" + sort;
    if (from) param += "&from=" + from;
    if (nearby) param += "&nearby=" + nearby;
    if (sjlm) param += "&sjlm=" + sjlm;
    if (keyword) param += "&keyword=" + keyword;


    if (from == "yp") {
        $("#aCommend").show();
        $("#aGoodAppr").hide();
        $("#aAuth").hide();
        $("#asjlm").hide();

        $("#ul_order_eat").hide();
        $("#ul_order_yp").show();
    } else {
        $("#ul_order_yp").hide();
        $("#ul_order_eat").show();

        $("#aCommend").hide();
        $("#aGoodAppr").show();
        $("#aAuth").show();
        $("#asjlm").show();
    }

    $.ajax({
        type: "POST",
        async: true,
        url: "Handler/map.ashx?type=new&method=getBusiness" + param,
        dataType: "json",
        success: function (result) {
            if (result) {
                mapcontrol.init(result[0]);
            }
        },
        error: function (e) {
            var aa = e;
        }
    });
}


function loadleft(leftdata, pageindex) {
    $(".listpage").show();
    if (!leftdata || leftdata.length < 1) {
        $("#pagecount").html('');
        $("#leftpage").html("");
        $(".listpage").hide();
        $("#leftdata").html('<span class="nonumber">暂无数据</span>');
        return;
    }
    var inhtml = "", startnum = 0, endnum = pagesize;
    if (pageindex != 1) { startnum = (pageindex - 1) * pagesize + 1; endnum = (pageindex - 1) * pagesize + pagesize + 1; }
    if (leftdata.length && endnum > leftdata.length) endnum = leftdata.length;
    var pagenum = parseInt((leftdata.length + pagesize - 1) / pagesize);
    $("#leftdata").html("");
    for (var i = startnum; i < endnum; i++) {

        
        var title = mapcontrol.addLeftEvent(leftdata[i]);

        var dl = document.createElement('dl');
        dl.className = "list-dl";
        var dt = document.createElement('dt');
        dt.className = "list-dl-icon";
        dt.innerHTML = leftdata[i].rownum;
        dl.appendChild(dt);

        var dd = document.createElement('dd');
        dd.className = "list-dd-cont";

        var div1 = document.createElement('div');
        div1.className = "list-dd-top";
        var ul1 = document.createElement('ul');
        var lititle = document.createElement('li');
        lititle.className = "list-dd-name";
        lititle.appendChild(title[0]);
        lititle.appendChild(title[1]);
        if (leftdata[i].from == "eat") {
            var listar = document.createElement('li');
            listar.className = "list-dd-mesg";
            listar.innerHTML = '<p class="staricon"><em style="width:' + parseInt(leftdata[i].starnum) * 20 + '%"> </em><span></span></p><i> <a href="#"> ' + leftdata[i].comments + '条评论 </a></i>';
            lititle.appendChild(listar);
        }
        ul1.appendChild(lititle);

        var litel = document.createElement('li');
        litel.className = "list-dd-phone";
        litel.innerHTML = leftdata[i].tel;
        ul1.appendChild(litel);

        var liaddress = document.createElement('li');
        liaddress.className = "address";
        liaddress.innerHTML = '<a href="javascript:void(0);">' + leftdata[i].street + '<br />' + leftdata[i].areaname + ',  ' + "ON  " + leftdata[i].postcode + '</a>';
        ul1.appendChild(liaddress);
        div1.appendChild(ul1);
        var span = document.createElement('span');
        span.className = "list-dd-pic fr";
        span.innerHTML = '<a href="javascript:void(0);"><img src="' + leftdata[i].logo + '" width="88px" height="66px" /></a>';
        div1.appendChild(span);

        var div2 = document.createElement('div');
        div2.className = "list-dd-bottom";
        var ul2 = document.createElement('ul');
        var libtn = document.createElement('li');
        var btn = '';
        btn += '<div class="set"><a href="javascript:void(0);">' + leftdata[i].subcategoryname + '</a></div>';
        btn += '<div class="operate">';
        btn += '<a href="javascript:void(0);" class="icon01" οnclick="favBusiness(' + leftdata[i].itemid + ',\'' + leftdata[i].from + '\')">收藏</a>';
        btn += '<a href="javascript:void(0);" class="icon02 street" lat="' + leftdata[i].lat + '" lng="' + leftdata[i].lng + '">街景</a>';
        btn += ' <a href="javascript:void(0);" class="icon03" οnclick="___show_error()">纠错</a>';
        btn += ' </div>';
        libtn.innerHTML = btn;
        ul2.appendChild(libtn);
        div2.appendChild(ul2);

        dd.appendChild(div1);
        dd.appendChild(div2);
        dl.appendChild(dd);
        $("#leftdata").append(dl);
    }

    var pagestring = GetListPageNumber(pageindex, pagenum, 6, "leftpage");
    $("#pagecount").html('[ 共 <b>' + pagenum + '</b> 页 ]');
    $("#leftpage").html(pagestring);
}


function showStreet(lat, lng) {
    $("#hdnisstreet").val("1");

    $('.left').animate({
        left: "-358"
    }, 500, function () {
        $(".arrow01").show();
    });
    docwidth = getDocWidth();
    docheight = getDocHeight();
    var width = docwidth, height = docheight - 120;
    $("#streetview").css({ "width": width, "height": height });
    var fenway = new google.maps.LatLng(lat, lng);
    var panoramaOptions = {
        position: fenway,
        pov: {
            heading: 34,
            pitch: 10,
            zoom: 1
        }
    };
    $('#googleMap').animate({
        right: "0",
        top: docheight - 420,
        width: "300",
        height: "300"
    }, 500);

    mapcontrol.panorama = new google.maps.StreetViewPanorama(document.getElementById("streetview"), panoramaOptions);
    mapcontrol.map.setStreetView(panorama);
}




function getDocWidth() {
    return document.documentElement.clientWidth || document.body.clientWidth;
}

function getDocHeight() {
    return document.documentElement.clientHeight || document.body.clientHeight;
}

function ___show_error() {
    initWebWindow('web-win-001', '我来挑错', '<div><iframe width="584" scrolling="no" height="286px" frameborder="no" src="/errorCorrection.aspx?t=' + Math.random() + '" id="iframeArticle"></iframe></div>', 584, 295);
}


function searchbusiness(event) {
    event = window.event || event;
    if (event.keyCode == 13) {
        var key = $.trim($("#txtSearch").val());
        if (key == "" || key == "搜索行业、商家、菜名、地址、邮编等等") return;
        $("#hdnkeyword").val(key);
        mapcontrol.isMapReload = false;
        businessBind();
        $("#txtSearch").val("");
        $("#hdnkeyword").val("");
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值