/** * * Color picker * Author: Stefan Petre www.eyecon.ro * * Dual licensed under the MIT and GPL licenses * */ (function ($) { var ColorPicker = function () { var ids = {}, inAction, charMin = 65, visible, tpl = '
"; // countlabel searchresultshtml += ' | ';
var zoom = mapZoom();
var zoomimg = "";
if(searchdiv != 'routing-result') {
zoomimg = (browser=='IE' && version<=6) ? "" : "";
}
var viewimg = "";
if(searchdiv != 'routing-result' && num_location_image>0) {
viewimg += (browser=='IE' && version<=6) ? "" : " ";
}
var eventimg = "";
if(searchdiv != 'routing-result' && num_location_event>0) {
eventimg += (browser=='IE' && version<=6) ? "" : " ";
}
var routeimg = false;
if(searchdiv == 'routing-result') {
routeimg = true;
}
if (type == "poi" || type == "osmp" || type == "foursquare-poi" || type == "google-poi" || type == "osm-poi") {
var name_padded = id;
var markpoijs = 'selectMapTab();';
var markpoiandzoomjs = 'selectMapTab();';
if(type == "poi" || type == "osmp") {
while (name_padded.length < 8) name_padded = "0" + name_padded;
if (n_pois == 1) {
markpoijs += 'markPOIandZoom(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", 17 , '', 1);";
} else {
markpoijs += 'markPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", " + zoom + " , '');";
}
markpoiandzoomjs += 'markPOIandZoom(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + "," + showlevel + ", '', 1);";
} else { //if(type == "foursquare-poi") {
if (n_pois == 1) {
markpoijs += 'markPOIandZoom(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", 17 , '', 1);";
} else {
markpoijs += 'markOtherServiceSearchPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", " + zoom + ");";
}
markpoiandzoomjs += 'markOtherServiceSearchPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + "," + showlevel + ", 1);";
}
searchresultshtml += '' + usename_org + "" + (type == "osmp" ? " " : '');
if(zoomimg!="") {
search_result_icon += ' ' + zoomimg + "";
}
if(viewimg!="") {
search_result_icon += ' ' + viewimg + '';
}
if(eventimg!="") {
search_result_icon += ' ' + eventimg + '';
}
if(routeimg) {
search_result_icon += ' ';
}
} else if (type == "road") {
searchresultshtml += '' + usename_org + ""; // '+type_road_text+':
if(zoomimg!="") {
search_result_icon += ' ' + zoomimg + "";
}
if(routeimg) {
search_result_icon += ' ';
}
} else if (type == "khet") {
var js_func = '';
var zoom_js_func = '';
if(geocode) {
js_func = 'focusLongdoPOI('+lat+', '+mylong+', '+geocode+', false, \'IG\');';
zoom_js_func = 'focusLongdoPOI('+lat+', '+mylong+', '+geocode+', true, \'IG\');';
} else {
js_func = 'markPOI(-1 ,\'' + usename + '\',' + lat +',' + mylong + ', ' + zoom + ', \' '+usedesc+'\');'; zoom_js_func = 'markPOIandZoom(-1 ,\'' + usename + '\',' + lat +',' + mylong + ', ' + zoom + ', \' '+usedesc+'\');'; } if (lat && mylong) { searchresultshtml += '' + usename_org + ""; } else { // probably only KWANG here searchresultshtml += '' + usename_org + ""; } if(zoomimg!="") { search_result_icon += ' ' + zoomimg + ""; } if(routeimg) { search_result_icon += ' '; } } else if (type == "tag") { var tagname = name.replace(/^tag: /, ""); searchresultshtml += '' + name + ""; } else if (type == "geom") { var name_padded = id; while (name_padded.length < 8) name_padded = "0" + name_padded; searchresultshtml += '' + name + ""; if(viewimg!="") { search_result_icon += ' ' + viewimg + ''; } if(eventimg!="") { search_result_icon += ' ' + eventimg + ''; } if(routeimg) { search_result_icon += ' '; } } else if (type == "map" || type == "layer") { var name_padded = id; var ooi_prefix = (type == "map") ? 'M' : 'Y'; while (name_padded.length < 8) name_padded = "0" + name_padded; searchresultshtml += '' + name + ""; if(viewimg!="") { search_result_icon += ' ' + viewimg + ''; } if(eventimg!="") { search_result_icon += ' ' + eventimg + ''; } // } else if (type == "Panorama") { // var name_padded = id; // var ooi_prefix = 'P'; // while (name_padded.length < 8) name_padded = "0" + name_padded; // searchresultshtml += '' + name + ""; } else { var name_padded = id; var ds_type = ""; if (type == "water-line") { ooi_prefix = 'X'; ds_type = ooi_prefix + "ID"; } else if(type == "water-area") { ooi_prefix = 'W'; ds_type = ooi_prefix + "ID"; } else if(type == "building") { ooi_prefix = 'B'; ds_type = ooi_prefix + "ID"; } else if(type == "bus") { ooi_prefix = 'S'; ds_type = ooi_prefix + "ID"; } if (ds_type != '') { while (name_padded.length < 8) name_padded = "0" + name_padded; searchresultshtml += '' + name + ""; if(zoomimg!="") { search_result_icon += ' ' + zoomimg + ""; } } } if(search_result_icon != '') { search_result_icon = ' '; searchresultshtml += search_result_icon; } if(typeof(usedesc) != "undefined" && usedesc != "") { searchresultshtml += " "+ usedesc.substr(0,shortdesc_limit) + (usedesc.length > shortdesc_limit ? "..." : "") + ""; } searchresultshtml += " | |
";
var nextbookmark = bookmark + n_pois;
var more_result_func = 'setBookmark('+ nextbookmark + ', false, \''+searchform+'\'); doPreviousSearch(\''+search_key+'\', \''+searchform+'\');';
if(typeof(servicesearch) == 'string' && servicesearch == 'google')
more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\', \''+searchform+'\'); searchOtherService(\''+search_key+'\', \'google\', \''+next_token+'\', \''+searchform+'\');';
else if(typeof(servicesearch) == 'string' && servicesearch == 'foursquare')
more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\', \''+searchform+'\'); searchOtherService(\''+search_key+'\', \'foursquare\', \''+next_token+'\', \''+searchform+'\');';
else if(typeof(servicesearch) == 'string' && servicesearch == 'osm')
more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\', \''+searchform+'\'); searchOtherService(\''+search_key+'\', \'osm\', \''+next_token+'\', \''+searchform+'\');';
searchresultshtml += ' '+txt_more+' ';
searchresultshtml += " | "+gg_html_attribute+" | "; } } else { // no result if(bookmark == 0) { var at_least_characters = 2; if(search_key.length >= at_least_characters) { if(servicesearch == 'longdo') { searchresultshtml += "|
"+txt_no_search_result+" | ||
"+txt_enter_more_info.replace('%d', at_least_characters)+" |
'+title+': | '+desc+' |
---|---|
Type: | |
' + (self._lang == 'th' ? 'ที่มา' : 'Source') + ': | ' + datasource + ' |
'+ obj.aqi_value +'
'; self._mmmap_lib.drawMarker(markersrc, obj.location.lat, obj.location.lon, '', '', false, {offset: { x: 12, y: 28 }}, {longdomap: {markertype: 'aqiinfo', aqiinfo:obj}, popup:{size:{width:400}, detail: content} }); self._all_aqiinfo.push(obj); } if(!self._map_is_moving) { self.displayCenterMapAqi(); } } }); } this.displayAqicnInfo = function() { if(self.callajax_layer) { self.callajax_layer.abort(); } self._map.Tags.add(self.getAqicnEachTile); } this.generateAqiDetails = function(obj, src) { var src_url = src == 'cn' ? 'http://aqicn.org/' : 'http://air4thai.pcd.go.th/'; var close_div_tag = true; var content = ''+ obj.aqi_value +'
'; content = self.generateAqiDetails(obj, 'air4thai'); self._mmmap_lib.drawMarker(markersrc, obj.location.lat, obj.location.lon, '', '', false, {offset: { x: 12, y: 28 }}, {longdomap: { markertype: 'aqiinfo' }, popup:{size:{width:400}, detail: content} }); self._all_aqiinfo.push(obj); } if(!self._map_is_moving) { self.displayCenterMapAqi(); } } }); } this.displayAqicnDetails = function(aqiinfo) { self._lib.callAjax(self._basepath_ws + '/webservice/json/getaqicninfo', { parameters: 'op=getaqicninfo&id='+aqiinfo.id+'×tamp='+self._lib.getTimestampForHour(), onSuccess: function(data) { var rs = JSON.parse(data.responseText); aqiinfo.aqi_info = rs.result; var content = self.generateAqiDetails(aqiinfo, 'cn'); $('.ldmap_popup_detail').html(content); } }); } this.showCenterMapAqi = function() { if(!self._map || (self._selected_layer != 'aqicn' && self._selected_layer != 'air4thai')) return; var map_div = self._placeholder_mapdiv; if(!map_div || typeof(map_div) != 'object') return; var _div = document.getElementById(self._centermap_aqi_div); var content = ''; if (_div) { if (_div.style.display == 'none') { _div.style.display = 'flex'; } } else { _div = document.createElement("div"); _div.id = self._centermap_aqi_div; _div.innerHTML = content; _div.style.position = 'absolute'; _div.style.top = '40px'; _div.style.right = '8px'; _div.style.fontSize = '1.5em'; _div.style.width = '75px'; _div.style.height = '75px'; _div.style.border = '1.3px solid #ffffff'; // _div.style.padding = '10px'; _div.style.display = 'flex'; _div.style.flexDirection = 'column'; _div.style.justifyContent = 'center'; _div.style.alignItems = 'center'; _div.style.boxShadow = '0px 1px 4px 0px rgba(0, 0, 0, 0.3)'; _div.style.backgroundColor = '#ffffff'; _div.style.opacity = '1'; _div.style.borderRadius = '4px'; _div.style.opacity = '0.8'; _div.style.cursor = 'pointer'; _div.style.zIndex = 1; map_div.appendChild(_div); //_div.addEventListener('click', function() { if(this.lat && this.lon) { self._map.location({lat: this.lat, lon: this.lon});} }); _div.addEventListener('click', function() { var win = window.open('https://traffic.longdo.com/airquality', '_blank'); win.focus(); }); } } this.hideCenterMapAqi = function() { var _div = document.getElementById(self._centermap_aqi_div); if (_div) { _div.lat = 0; _div.lon = 0; _div.style.display = 'none'; } } this.displayCenterMapAqi = function() { if(self._selected_layer != 'aqicn' && self._selected_layer != 'air4thai') return; var mode = self._selected_layer; self.showCenterMapAqi(); var minimunDistance = 50000; //50km var nearAqiValue = '-'; var nearAqiFontColor = '#333'; var nearAqiBgColor = '#fff'; var nearbyAqiIcon = ''; var nearbyAqiLat = 0; var nearbyAqiLon = 0; var nearbyAqiTextalign = 'center'; var num = self._all_aqiinfo.length; var obj; for(var i=0; i' + item.name + ' | '; innerHTML += '' + (Number(item.value) !== 0 ? Number(item.value).toLocaleString() : ' ' + _translate[_lang].no_data + ' ') + ' | ';
innerHTML += '' + item.unit + ' | '; innerHTML += '