XWWitPark/witpark_szjsc/xw_szjsc_web/public/widgets/navXZQH/view.js

2 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-09-12 00:10:00 +00:00
/* 2020-9-24 14:48:22 | 版权所有 军懋国兴 */
var thisWidget;function initWidgetView(t){(thisWidget=t).config&&thisWidget.config.style&&$("body").addClass(thisWidget.config.style),$("#xzqh-select").citypicker({simple:!0});var i=$("#xzqh-select");i.hide(),i.citypicker("open");var s=-1;$(".city-picker-dropdown").on("click",".city-select a",function(){var t=String(i.data("citypicker").getCode()),e=i.data("citypicker").getVal();$("#cityname").html(e),-1!=s&&(clearTimeout(s),s=-1),s=setTimeout(function(){centerAtRegion(t,e)},200)})}function centerAtRegion(t,e){var i,s;"0000"==t.substring(2)?(i="/geojson/xzqh/sheng/china.json",s=t.substring(0,2)):"00"==t.substring(4)?(i="/geojson/xzqh/shi/"+t.substring(0,2)+".json",s=t.substring(0,4)):(i="/geojson/xzqh/xian/"+t.substring(0,4)+"00.json",s=t,$("#con_wdx_1").hide()),$.getJSON(serverURL_file+i,function(t){if(thisWidget.isActivate)for(var e=t.features.length,i=0;i<e;i++)if(t.features[i].properties.id==s){thisWidget.showRegionExtent(t.features[i]);break}});var n=e.lastIndexOf("/");-1!=n&&(e=e.substring(n+1)),e.length<=2?e+="&nbsp;":3<e.length&&(e=e.substring(0,2)+".."),$("#xzqh_sel").html(e)}function goHome(){$("#cityname").html(""),$("#xzqh-select").citypicker("reset"),thisWidget.goHome()}