var tdbLocationDisplay={};jQuery().ready(function(){tdbLocationDisplay.init()});
(function(){tdbLocationDisplay={items:[],item:function(){this.blockObj=this.uid="";this.APIService="google";this.mapMarker=this.map=void 0;this.address="";this._is_initialized=!1},init:function(){tdbLocationDisplay.items=[];this._is_running=!1},_initialize_item:function(a){!0!==a._is_initialized&&(tdbLocationDisplay.initMap(a),a._is_initialized=!0)},addItem:function(a){if("undefined"===typeof a.uid)throw"item.uid is not defined";tdbLocationDisplay.items.push(a);tdbLocationDisplay._initialize_item(a)},
initMap:function(a){var b=document.querySelector("."+a.uid+" .tdb-sld-map"),c={lat:0,lng:0};switch(a.APIService){case "google":a.map=new google.maps.Map(b,{center:c,zoom:3});a.mapMarker=new google.maps.Marker({position:c,map:a.map});(new google.maps.Geocoder).geocode({address:a.address},function(b,c){"OK"===c&&(b=b[0].geometry.location,tdbLocationDisplay.updateMap(a,b.lat(),b.lng(),15))});break;case "bing":a.map=new Microsoft.Maps.Map(b,{center:new Microsoft.Maps.Location(c.lat,c.lng),zoom:a.defZoom,
showLocateMeButton:!1}),Microsoft.Maps.loadModule(["Microsoft.Maps.AutoSuggest","Microsoft.Maps.Search"],function(){(new Microsoft.Maps.Search.SearchManager(a.map)).geocode({where:a.address,callback:function(b){b&&b.results&&0<b.results.length&&setTimeout(function(){tdbLocationDisplay.updateMap(a,b.results[0].location.latitude,b.results[0].location.longitude,15)},400)}})})}},updateMap:function(a,b,c,d){switch(a.APIService){case "google":b=new google.maps.LatLng(b,c);a.map.setCenter(b);a.map.setZoom(d);
a.mapMarker.setPosition(b);break;case "bing":a.map.setView({mapTypeId:Microsoft.Maps.MapTypeId.road,center:new Microsoft.Maps.Location(b,c),zoom:d}),a.map.entities.clear(),a.map.entities.push(new Microsoft.Maps.Pushpin({altitude:0,altitudeReference:-1,latitude:b,longitude:c}))}},deleteItem:function(a){for(var b=0;b<tdbLocationDisplay.items.length;b++)if(tdbLocationDisplay.items[b].uid===a)return tdbLocationDisplay.items.splice(b,1),!0;return!1},resetItems:function(){tdbLocationDisplay.items=[]}}})();
