(result)
| 5603 | |
| 5604 | //根据IP定位 |
| 5605 | function locationFun(result){ |
| 5606 | var cityName = result.name; |
| 5607 | map.setCenter(cityName); |
| 5608 | |
| 5609 | // 设置城市名称 |
| 5610 | $cityInput.val(cityName); |
| 5611 | if (E.placeholder) { |
| 5612 | $searchInput.focus(); |
| 5613 | } |
| 5614 | var timeoutId, searchFn; |
| 5615 | if (inputKeyup) { |
| 5616 | // 并绑定搜索事件 - input 支持 keyup |
| 5617 | searchFn = function (e) { |
| 5618 | if (e.type === 'keyup' && e.keyCode === 13) { |
| 5619 | e.preventDefault(); |
| 5620 | } |
| 5621 | if (timeoutId) { |
| 5622 | clearTimeout(timeoutId); |
| 5623 | } |
| 5624 | timeoutId = setTimeout(mapData.searchMap, 500); |
| 5625 | }; |
| 5626 | $cityInput.on('keyup change paste', searchFn); |
| 5627 | $searchInput.on('keyup change paste', searchFn); |
| 5628 | } else { |
| 5629 | // 并绑定搜索事件 - input 不支持 keyup |
| 5630 | searchFn = function () { |
| 5631 | if (!$content.is(':visible')) { |
| 5632 | // panel 不显示了,就不用再监控了 |
| 5633 | clearTimeout(timeoutId); |
| 5634 | return; |
| 5635 | } |
| 5636 | |
| 5637 | var currentCity = ''; |
| 5638 | var currentSearch = ''; |
| 5639 | var city = $cityInput.val(); |
| 5640 | var search = $searchInput.val(); |
| 5641 | |
| 5642 | if (city !== currentCity || search !== currentSearch) { |
| 5643 | // 刚获取的数据和之前的数据不一致,执行查询 |
| 5644 | mapData.searchMap(); |
| 5645 | // 更新数据 |
| 5646 | currentCity = city; |
| 5647 | currentSearch = search; |
| 5648 | } |
| 5649 | |
| 5650 | // 继续监控 |
| 5651 | if (timeoutId) { |
| 5652 | clearTimeout(timeoutId); |
| 5653 | } |
| 5654 | timeoutId = setTimeout(searchFn, 1000); |
| 5655 | }; |
| 5656 | // 开始监控 |
| 5657 | timeoutId = setTimeout(searchFn, 1000); |
| 5658 | } |
| 5659 | } |
| 5660 | var myCity = new BMap.LocalCity(); |
| 5661 | myCity.get(locationFun); |
| 5662 |
nothing calls this directly
no outgoing calls
no test coverage detected