scheduler.xy.map_date_width = 188; // date column width scheduler.xy.map_description_width = 400; // description column width scheduler.config.map_resolve_event_location = true; // if events in database doesn't have lat and lng values there will be an attempt to resolve them on event loading, useful for migration scheduler.config.map_resolve_user_location = true; // if user will be promted to share his location to display it on the map scheduler.config.map_initial_position = new google.maps.LatLng(48.724, 8.215); // inital position of the map scheduler.config.map_error_position = new google.maps.LatLng(15, 15); // this position will be displayed in case if event doesn't have corresponding coordinates scheduler.config.map_infowindow_max_width = 300; scheduler.config.map_type = google.maps.MapTypeId.ROADMAP; scheduler.config.map_zoom_after_resolve = 15; scheduler.locale.labels.marker_geo_success = "It seems you are here."; scheduler.locale.labels.marker_geo_fail = "Sorry, could not get your current position using geolocation."; scheduler.templates.marker_date=scheduler.date.date_to_str("%Y-%m-%d %H:%i"); // date for map's infowindow will be formated following way scheduler.templates.marker_text=function(start, end, ev){ return "
"+ev.text+"

"+(ev.event_location||'')+"

"+scheduler.templates.marker_date(start)+" - "+scheduler.templates.marker_date(end)+"
"; }; scheduler.dblclick_dhx_map_area=function(){ if (!this.config.readonly && this.config.dblclick_create) this.addEventNow(); }; scheduler.templates.map_time = function(start,end,ev){ if (ev._timed) return this.day_date(ev.start_date, ev.end_date, ev)+" "+this.event_date(start); else return scheduler.templates.day_date(start)+" – "+scheduler.templates.day_date(end); }; scheduler.templates.map_text = function(ev){ return ev.text; }; scheduler.date.map_start=function(d){ return d; }; scheduler.attachEvent("onTemplatesReady",function(){ function _append_map() { _isPositionSet = false; // if user actual (geolocation) position was set on the map var gmap = document.createElement('div'); gmap.className='dhx_map'; gmap.id='dhx_gmap'; gmap.style.dispay = "none"; node = document.getElementById('scheduler_here'); node.appendChild(gmap); scheduler._els.dhx_gmap = []; scheduler._els.dhx_gmap.push(gmap); _setMapSize('dhx_gmap'); var mapOptions = { zoom: scheduler.config.map_inital_zoom || 10, center: scheduler.config.map_initial_position, mapTypeId: scheduler.config.map_type||google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('dhx_gmap'), mapOptions); map.disableDefaultUI = false; map.disableDoubleClickZoom = true; google.maps.event.addListener(map, "dblclick", function(event) { if (!scheduler.config.readonly && scheduler.config.dblclick_create) { point = event.latLng; geocoder.geocode( { 'latLng': point }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { point = results[0].geometry.location; scheduler.addEventNow({ lat: point.lat(), lng: point.lng(), event_location: results[0].formatted_address }); } } ); } }); var infoWindowOptions = { content: '' }; if (scheduler.config.map_infowindow_max_width) { infoWindowOptions.maxWidth = scheduler.config.map_infowindow_max_width; } scheduler.map = { _points: [], _markers: [], _infowindow: new google.maps.InfoWindow(infoWindowOptions), _infowindows_content: [], _initialization_count: -1 }; geocoder = new google.maps.Geocoder(); if(scheduler.config.map_resolve_user_location) { if(navigator.geolocation) { if(!_isPositionSet) { navigator.geolocation.getCurrentPosition(function(position) { var _userLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); map.setCenter(_userLocation); map.setZoom(scheduler.config.map_zoom_after_resolve||10); scheduler.map._infowindow.setContent(scheduler.locale.labels.marker_geo_success); scheduler.map._infowindow.position = map.getCenter(); scheduler.map._infowindow.open(map); _isPositionSet = true; }, function() { scheduler.map._infowindow.setContent(scheduler.locale.labels.marker_geo_fail); scheduler.map._infowindow.setPosition(map.getCenter()); scheduler.map._infowindow.open(map); _isPositionSet = true; }); } } } google.maps.event.addListener(map, "resize", function(event) { gmap.style.zIndex='5'; map.setZoom( map.getZoom() ); }); google.maps.event.addListener(map, "tilesloaded", function(event) { gmap.style.zIndex='5'; }); } _append_map(); scheduler.attachEvent("onSchedulerResize",function(){ if (this._mode == "map"){ this.map_view(true); } }); var old = scheduler.render_data; scheduler.render_data=function(evs,hold){ if (this._mode == "map") { fill_map_tab(); var events = scheduler.get_visible_events(); for(var i=0; i
"+l.date+"
"+l.description+"
"; scheduler._table_view=true; scheduler.set_sizes(); } } function fill_map_tab(){ //get current date var date = scheduler._date; //select events for which data need to be printed var events = scheduler.get_visible_events(); events.sort(function(a,b){ return a.start_date>b.start_date?1:-1; }); //generate html for the view var html="
"; for (var i=0; i
"+scheduler.templates.map_time(events[i].start_date, events[i].end_date,events[i])+"
"; html+="
 
"; html+="
"+scheduler.templates.map_text(events[i])+"
"; // -25 = icon size 20 and padding 5 } html+="
"; //render html scheduler._els["dhx_cal_data"][0].scrollTop = 0; //fix flickering in FF scheduler._els["dhx_cal_data"][0].innerHTML = html; scheduler._els["dhx_cal_data"][0].style.width = (scheduler.xy.map_date_width + scheduler.xy.map_description_width + 1) + 'px'; var t=scheduler._els["dhx_cal_data"][0].firstChild.childNodes; scheduler._els["dhx_cal_date"][0].innerHTML=""; scheduler._rendered=[]; for (var i=0; i < t.length-2; i++) { scheduler._rendered[i]=t[i]; } } function _setMapSize(elem_id) { //input - map's div id var map = document.getElementById(elem_id); map.style.height = (scheduler._y - scheduler.xy.nav_height) + 'px'; map.style.width = (scheduler._x - scheduler.xy.map_date_width - scheduler.xy.map_description_width - 1) + 'px'; map.style.marginLeft = (scheduler.xy.map_date_width + scheduler.xy.map_description_width + 1) + 'px'; map.style.marginTop = (scheduler.xy.nav_height + 2) + 'px'; } scheduler.map_view=function(mode){ scheduler.map._initialization_count++; var gmap = scheduler._els.dhx_gmap[0]; scheduler._els.dhx_cal_data[0].style.width = (scheduler.xy.map_date_width + scheduler.xy.map_description_width + 1) + 'px'; scheduler._min_date = scheduler.config.map_start||(new Date()); scheduler._max_date = scheduler.config.map_end||(new Date(9999,1,1)); scheduler._table_view = true; set_full_view(mode); if (mode){ //map tab activated fill_map_tab(); gmap.style.display = 'block'; // need to resize block everytime window is resized _setMapSize('dhx_gmap'); var events = scheduler.get_visible_events(); for(var i=0; i