RT 这段时间在弄一个需要使用到地图的项目,然后公司选择使用高德地图,各项功能都基本完善了,但是...当输入地址为很详细的那种时..搜索不到,也定位不到...试了很多办法,但是依然没用..已经要哭了我贴一下地图的JS代码,希望大神指点下我是不是有哪写得有问题....
/**
 * Created by JmeoM on 2015/10/19.
 *
 */$.tmap = {
    ops:{zoom:14,resizeEnable:true},
    ers : []
};var tmap = {
    initMap: function (container, ops) {
        //初始化地图 --> 生成 mapobj
        var option = $.extend({}, $.tmap.ops,ops);
        var mapObj = new AMap.Map(container,option);
        $.tmap.map = mapObj;
    },
    autoComplete: function (input,callback) {
        //自动填充插件
        AMap.service(['AMap.Autocomplete'], function () {
            var option = {input:input};
            var autoComplete = new AMap.Autocomplete(option);
            $.tmap.autoComplete = autoComplete;
            AMap.event.addListener(autoComplete,'select', function (e) {
                tmap.clearMarkers();
                if(callback){
                    callback(e);
                }
            });
        });
    },
    searchPlace: function (address,callback) {
        //地址搜索
        AMap.service(['AMap.PlaceSearch'], function () {
            if(!address){return;}
            var placeSearch = new AMap.PlaceSearch({});            placeSearch.search(address, function (status,result) {
                if(status == 'complete'){
                    if(callback){
                        callback(result);
                    }
                }
            });
        });
    }
    : function (option) {
        //标记坐标点
        var er = new AMap.Marker(option);
        $.tmap.ers.push(er);
            er.content="地址:"+er.Rd.title;
            er.on("click",function (e) {
                var extData=this.getExtData();
                $("li","#resultList").eq(extData.index).click();
            })
        return er;
    },
    clearMarkers: function () {
        //清理地图标记
        var ters = $.tmap.ers || [];
        for (var i = 0; i < ters.length; i++) {
            var  = ters[i]
            if () {
                .setMap(null);
            }
        }
        $.tmap.ers = [];
    },
    searchAction: function (address) {
        tmap.searchPlace(address, function (searchResult) {
            debugger;
            var lat=searchResult.poiList.pois[0].location.lat;
            var lng=searchResult.poiList.pois[0].location.lng;
            $.tmap.map.setCenter(new AMap.LngLat(lng,lat));
            var list = searchResult.poiList.pois;
            var ul=$("<ul id='resultListUl' style='list-style: none'></ul>");
            for(var i=0;i<list.length;i++){
                var poi = list[i];
                poi.index=i;
                var li=$("<li class='poibox'><div class='amap_lib_placeSearch_poi poibox-icon'>"+(i+1)+"</div><div id='positionName'>"+poi.name+"</div><div id='address'>地址:"+poi.address+"</div></li>");
                li.data('data',list[i]);
                ul.append(li);
                tmap.({
                    position:poi.location,
                    title:poi.name,
                    extData:poi,
                    map: $.tmap.map
                });
            }            $("li",ul).on("click",function () {
                $("li",ul).removeClass('active');
                $(this).addClass('active');
                var data=$(this).data("data");
                var er = new AMap.Marker({
                    position:data.location,
                    title:data.name,
                    extData:data,
                    map: $.tmap.map
                });
                $.tmap.ers.push(er);
                var infoWindow=new AMap.InfoWindow();
                er.content="地址:"+er.Rd.title;
                infoWindow.setContent(er.Rd.title);
                infoWindow.open($.tmap.map, er.Rd.position);
                getDealerInfo(data.location.lat,data.location.lng);
            });
            $("#resultList").show();
            $("#resultList").html(ul);
            $("li","#resultListUl").first().click();
        });    },
    init: function () {
        //初始化地图
        tmap.initMap('container');
        tmap.autoComplete('mapAddress', function (selectItem) {
            tmap.searchAction(selectItem.poi.name);
        })
    }
};额...公司网络有点差...运行结果图片发不上,我在下面楼发下试试