define(['jquery', 'backbone', 'underscore', 'leaflet', 'moxie.conf', 'moxie.position', 'places/utils', 'hbs!places/templates/list-map-layout', 'hbs!places/templates/detail', 'hbs!places/templates/busrti'],
    function($, Backbone, _, L, MoxieConf, userPosition, placesUtils, baseTemplate, detailTemplate, busRTITemplate){
    var DetailView = Backbone.View.extend({

        initialize: function() {
            _.bindAll(this);
        },

        attributes: {
            'class': 'detail-map'
        },

        render: function() {
            this.$el.html(baseTemplate());
            this.map = placesUtils.getMap(this.$('#map')[0]);
            userPosition.follow(this.handle_geolocation_query);
            this.requestPOI();
            return this;
        },

        navigateBack: function(ev) {
            ev.preventDefault();
            if(this.marker) {
                this.map.removeLayer(this.marker);
            }
            this.cb();
            this.onClose();
        },

        invalidateMapSize: function() {
            this.map.invalidateSize();
            return this;
        },

        requestPOI: function() {
            var url = MoxieConf.urlFor('places_id') + this.options.poid;
            $.ajax({
                url: url,
                dataType: 'json'
            }).success(this.getDetail);
        },

        getDetail: function(data) {
            this.poi = new this.model(data);
            this.renderPOI();
        },

        updateMap: function() {
            if (this.user_position && this.latlng) {
                this.map.fitBounds([
                    this.user_position,
                    this.latlng
                ]);
            } else if (this.user_position) {
                this.map.panTo(this.user_position);
            } else if (this.latlng) {
                this.map.panTo(this.latlng);
            }
        },

        renderPOI: function(cb) {
            if (cb) {
                this.delegateEvents(this.events);
                this.cb = cb;
                $('#home').hide();
                // Event has to be bound here as the events hash only binds to items within this.el
                // TODO: Common code for this stuff.
                $('#back').show().on('click', this.navigateBack);
            }
            Backbone.trigger('domchange:title', this.poi.attributes.name);
            var rti = this.poi.attributes._links['hl:rti'];
            var context = {'poi': this.poi, 'rti': rti};
            this.$("#list").html(detailTemplate(context));
            this.$el.scrollTop(0);
            if(this.poi.get('lat') && this.poi.get('lon')) {
                this.latlng = new L.LatLng(this.poi.get('lat'), this.poi.get('lon'));
                this.marker = new L.marker(this.latlng, {'title': this.poi.get('name')});
                this.marker.addTo(this.map);
            }
            this.updateMap();
            if (rti) {
                var url = MoxieConf.endpoint + rti.href;
                $.ajax({
                    url: url,
                    dataType: 'json'
                }).success(this.renderRTI);
            }
        },

        renderRTI: function(data) {
            this.$('#poi-rti').html(busRTITemplate(data));
        },

        geo_error: function(error) {
            if (!this.user_position) {
                console.log("No user location");
            }
        },

        handle_geolocation_query: function(position) {
            this.user_position = [position.coords.latitude, position.coords.longitude];
            var you = new L.LatLng(position.coords.latitude, position.coords.longitude);
            if (this.user_marker) {
                this.map.removeLayer(this.user_marker);
            }
            this.user_marker = L.circle(you, 10, {color: 'red', fillColor: 'red', fillOpacity: 1.0});
            this.map.addLayer(this.user_marker);
            this.updateMap();
        },

        onClose: function() {
            $('#back').hide().off('click');
            userPosition.unfollow(this.handle_geolocation_query);
        }

    });
    return DetailView;
});

@@ -316,16 +316,64 @@
 plate)%7B%0A
+%0A    var RTI_REFRESH = 15000;    // 15 seconds%0A%0A
     var 
@@ -2433,20 +2433,21 @@
         
-var 
+this.
 rti = th
@@ -2533,16 +2533,21 @@
  'rti': 
+this.
 rti%7D;%0A  
@@ -2980,16 +2980,21 @@
     if (
+this.
 rti) %7B%0A 
@@ -3012,47 +3012,84 @@
     
-var url = MoxieConf.endpoint + rti.href
+this.refreshRTI();%0A                setInterval(this.refreshRTI, RTI_REFRESH)
 ;%0A  
@@ -3094,36 +3094,37 @@
             
+%7D%0A
     
-$.ajax(%7B
+    %7D,%0A
 %0A           
@@ -3120,37 +3120,102 @@
         
-            url: url,
+renderRTI: function(data) %7B%0A            this.$('#poi-rti').html(busRTITemplate(data));
 %0A       
@@ -3211,32 +3211,36 @@
 ));%0A        
+%7D,%0A%0A
         
     dataType
@@ -3231,71 +3231,89 @@
     
-    dataType: 'json'%0A                %7D).success(this.renderRTI)
+refreshRTI: function() %7B%0A            var url = MoxieConf.endpoint + this.rti.href
 ;%0A  
@@ -3314,33 +3314,40 @@
 ef;%0A            
-%7D
+$.ajax(%7B
 %0A        %7D,%0A%0A   
@@ -3335,36 +3335,32 @@
 x(%7B%0A        
-%7D,%0A%0A
         
 renderRTI: f
@@ -3351,92 +3351,88 @@
     
-renderRTI: function(data) %7B%0A            this.$('#poi-rti').html(busRTITemplate(data)
+url: url,%0A                dataType: 'json'%0A            %7D).success(this.renderRTI
 );%0A 

Refresh RTI data every 15 seconds (TRELLO#188).