'Map page
@param r: the S3Request instance
@param attr: controller attributes for the request'

def page(self, r, **attr):

    if (r.representation in ('html', 'iframe')):
        response = current.response
        resource = self.resource
        get_config = resource.get_config
        tablename = resource.tablename
        widget_id = 'default_map'
        output = {}
        title = self.crud_string(tablename, 'title_map')
        output['title'] = title
        filter_widgets = get_config('filter_widgets', None)
        if (filter_widgets and (not self.hide_filter)):
            advanced = False
            for widget in filter_widgets:
                if (('hidden' in widget.opts) and widget.opts.hidden):
                    advanced = resource.get_config('map_advanced', True)
                    break
            request = self.request
            from s3filter import S3FilterForm
            S3FilterForm.apply_filter_defaults(r, resource)
            filter_formstyle = get_config('filter_formstyle', None)
            submit = resource.get_config('map_submit', True)
            filter_form = S3FilterForm(filter_widgets, formstyle=filter_formstyle, advanced=advanced, submit=submit, ajax=True, ajaxurl=r.url(method='filter', vars={}, representation='options'), _class='filter-form', _id=('%s-filter-form' % widget_id))
            get_vars = request.get_vars
            filter_form = filter_form.html(resource, get_vars=get_vars, target=widget_id)
        else:
            filter_form = ''
        output['form'] = filter_form
        output['map'] = self.widget(r, widget_id=widget_id, callback='S3.search.s3map()', **attr)
        response.view = self._view(r, 'map.html')
        return output
    else:
        r.error(415, current.ERROR.BAD_FORMAT)
