天地图--根据关键字本地搜索

天地图--根据关键字本地搜索 

 

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="天地图"/>
    <title>天地图-地图API-范例-根据关键字本地搜索</title>
    <style type="text/css">
        .search {
            font-size: 13px;
            border: 1px solid #999999;
        }

        .ls {
            line-height: 27px;
            padding-left: 7px;
        }

        .prompt {
            display: none;
            font-size: 13px;
            border: 1px solid #999999;
        }

        .statistics {
            display: none;
            font-size: 13px;
            border: 1px solid #999999;
            overflow-y: scroll;
            height: 150px;
        }

        .suggests {
            display: none;
            font-size: 13px;
            border: 1px solid #999999;
        }

        ;
        .lineData {
            display: none;
            font-size: 13px;
            border: 1px solid #999999;
        }

        .result {
            display: none;
            font-size: 12px;
            border: 1px solid #999999;
            line-height: 27px;
            padding-left: 7px;
        }
    </style>
    <script type="text/javascript" src="http://api.tianditu.gov.cn/api?v=4.0"></script>
    <style type="text/css">body,html{width:100%;height:100%;margin:0;font-family:"Microsoft YaHei"}#mapDiv{width:100%;height:400px}input,b,p{margin-left:5px;font-size:14px}</style>
    <script>
        var map;
        var zoom = 12;
        var localsearch;
        function onLoad() {
            //初始化地图对象
            map = new T.Map("mapDiv");
            //设置显示地图的中心点和级别
            map.centerAndZoom(new T.LngLat(116.40969, 39.89945), zoom);

            var config = {
                pageCapacity: 10,    //每页显示的数量
                onSearchComplete: localSearchResult    //接收数据的回调函数
            };
            //创建搜索对象
            localsearch = new T.LocalSearch(map, config);
        }

        function localSearchResult(result) {
            //清空地图及搜索列表
            clearAll();

            //添加提示词
            prompt(result);

            //根据返回类型解析搜索结果
            switch (parseInt(result.getResultType())) {
                case 1:
                    //解析点数据结果
                    pois(result.getPois());
                    break;
                case 2:
                    //解析推荐城市
                    statistics(result.getStatistics());
                    break;
                case 3:
                    //解析行政区划边界
                    area(result.getArea());
           

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值