/** * * 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 = '
"+snippet_code+"
















"+snippet_code+"
"+snippet_code+"

"+snippet_code+"











';
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 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)+" | ||



';
b1.onclick = function() {
var location = getCenterLocation();
markDroppedPinWithAnimation(location.lat, location.lon);
};
b1.onmouseover = function () {
$("#mm-addlocation-button").addClass("hover");
};
b1.onmouseout = function () {
$("#mm-addlocation-button").removeClass("hover");
};
$(".ldmap_toolbar").append(b1);
//canvas.addButton('customize', b1);
setDragableOnDropPin();
break;
}
}
function getMinMaxBoundary(obj, boundary) {
var lat, lon;
var num_points = obj.length;
for(var i=0; i
| '+title+': | '+desc+' |
|---|---|
| Type: | |
| ' + (self._lang == 'th' ? 'ที่มา' : 'Source') + ': | ' + datasource + ' |



', 'hide');
if (self._mmmap_lib.mapZoom() > maxzoom_limit) {
self._mmmap_lib.mapZoom(maxzoom_limit);
}
} else if(item.layer == 'rain_forecast_nextday') {
self._floodLayer = new longdo.Layer('rain_forecast_nextday', { type: longdo.LayerType.WMTS, url: self._basepath_maplayer+'/mapproxy/service/', srs: 'GLOBAL_WEBMERCATOR', tileMatrix: function(zoom) { return zoom < 10 ? '0' + zoom : zoom }, zoomRange: { min: 1, max: 13 }, opacity: 1, refresh:3600});
self.showMapLegend(item.label, '

', 'hide');
} else {
self._floodLayer = new longdo.Layer(item.layer, {opacity: 0.7});
self.hideMapLegend();
}
//self._map.Layers.add(self._floodLayer);
setTimeout(function(){self._map.Layers.add(self._floodLayer);}, 0);
if(/^ortho/.test(item.layer)) {
var normaltrans_layer = self._lang == 'th' ? 'NORMAL_TRANSPARENT' : 'NORMAL_TRANSPARENT_EN';
if(!longdo.Layers[normaltrans_layer]) {
longdo.Layers[normaltrans_layer] = new longdo.Layer('normaltransp', { url: 'https://ms.longdo.com/mmmap/img.php', opacity: 0.8 });
}
setTimeout(function(){self._map.Layers.add(longdo.Layers[normaltrans_layer]);}, 1);
}
}
} else {
self.hideMapLegend();
}
}
});
self._map.Ui.add(self._floodMenu);
var ldmapDropdownHead = self._floodMenu.element().querySelector('.ldmap_dropdown_head');
ldmapDropdownHead.onclick = () => {
var ldmapDropdownBody = self._floodMenu.element().querySelector('.ldmap_dropdown_body');
ldmapDropdownBody.style.maxHeight = ldmapDropdownBody.style.maxHeight != '0px' ? '0px' : 'calc(100vh - 81px)';
};
//floodMenu.element().children[0].style.width = '170px';
if (self._default_select_index >= 0) {
self._floodMenu.selectIndex(self._default_select_index);
}
/**
* ช่อง Filter ค้นหา
*/
var bodyMenuLayer = self._floodMenu.element().querySelector('.ldmap_dropdown_body');
var filterElement = document.createElement("input");
filterElement.type = 'search';
filterElement.style = '-webkit-appearance: none; -moz-appearance: none; appearance: none; outline: none; width: 100%; box-sizing: border-box; padding: 8px 8px 8px 8px; border-radius: 0px; border-left: none; border-right: none; border-top: none; border-bottom: 1px solid rgb(180, 180, 180);';
filterElement.placeholder = self._lang == 'th' ? 'ใส่ชื่อชั้นข้อมูล' : 'Insert layer name';
filterElement.addEventListener('input', function() {
var menuLayerList = bodyMenuLayer.querySelectorAll('.ldmap_option');
for (var i = 0; i < menuLayerList.length; i++) {
if (menuLayerList[i].innerHTML.toLowerCase().indexOf(filterElement.value.toLowerCase()) !== -1) {
menuLayerList[i].style.display = 'block';
} else {
menuLayerList[i].style.display = 'none';
}
}
});
bodyMenuLayer.insertBefore(filterElement, bodyMenuLayer.firstChild);
/**
* ช่อง Filter ค้นหา
*/
self.bindMapEvent();
}
this.clearLayerMarkers = function(type) {
var all_overlay = self._map.Overlays.list();
var num_overlay = all_overlay.length;
var obj;
for(var i=0; i'+ 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
');
// var content = (nearbyAqiIcon ? ' | ' + item.name + ' | '; innerHTML += '' + (Number(item.value) !== 0 ? Number(item.value).toLocaleString() : ' ' + _translate[_lang].no_data + ' ') + ' | ';
innerHTML += '' + item.unit + ' | '; innerHTML += '

');
}
_last_search_latitude = typeof lat == 'undefined' ? getCenterLocation().lat : lat;
_last_search_longitude = typeof lon == 'undefined' ? getCenterLocation().lon : lon;
var d = new Date;
var timestamp = d.getTime();
var bMark = (document.getElementById('routing-bookmark')) ? document.getElementById('routing-bookmark').value:'';
var showall = 20;
// var pars = "search=" + encodeURIComponent( searchterm )
// + "×tamp=" + encodeURIComponent( timestamp )
// + "&bookmark=" + encodeURIComponent(bMark)
// + "¢er_lat=" + encodeURIComponent( _last_search_latitude )
// + "¢er_long=" + encodeURIComponent( _last_search_longitude ) + "&map="
// + "&showall=" + encodeURIComponent( showall )
// + "&forcezoom="
// + "&resultdiv=routing-result"
// // + "&ds=change,con,data2"
// + "&action=searchxml";
// var url = '/mmmap/rpc.php';
// self._lib.callAjax(url, {method: 'get', parameters: pars, onSuccess: handleResponse});
var pars = "keyword=" + encodeURIComponent( searchterm )
+ "×tamp=" + encodeURIComponent( timestamp )
+ "&offset=" + encodeURIComponent(bMark)
+ "&lat=" + encodeURIComponent( _last_search_latitude )
+ "&lon=" + encodeURIComponent( _last_search_longitude )
+ "&locale=" + mylang
+ "&dataset=change,con,data2,tag,pg,nw,data2b,bus,osmpnt,osmline,osmpol"
// + "&extendedsearch=1&extendedlimit=3&extendedkey="+self._gg_api_key
self._lib.callAjax('https://search.longdo.com/smartsearch/json/search', {method: 'get', parameters: pars,
onSuccess: function(data) {
var rs = JSON.parse(data.responseText);
renderSearchResult(rs, '', showall, 'routing-result')
}
});
}
}
"+snippet_code+"




