def leaflet_json_config(): settings_as_json = app_settings.copy() if SPATIAL_EXTENT is not None: xmin, ymin, xmax, ymax = settings_as_json.pop('SPATIAL_EXTENT') settings_as_json['SPATIAL_EXTENT'] = { 'xmin': xmin, 'ymin': ymin, 'xmax': xmax, 'ymax': ymax } return json.dumps(settings_as_json)
def leaflet_json_config(): settings_as_json = app_settings.copy() if SPATIAL_EXTENT is not None: xmin, ymin, xmax, ymax = settings_as_json.pop("SPATIAL_EXTENT") settings_as_json["SPATIAL_EXTENT"] = {"xmin": xmin, "ymin": ymin, "xmax": xmax, "ymax": ymax} return json.dumps(settings_as_json)
def leaflet_json_config(): settings_as_json = app_settings.copy() if SPATIAL_EXTENT is not None: xmin, ymin, xmax, ymax = settings_as_json.pop('SPATIAL_EXTENT') settings_as_json['SPATIAL_EXTENT'] = {'xmin': xmin, 'ymin': ymin, 'xmax': xmax, 'ymax': ymax} return json.dumps(settings_as_json, cls=JSONLazyTranslationEncoder)
def leaflet_map(name, callback=None, fitextent=True, creatediv=True, loadevent=app_settings.get('LOADEVENT'), settings_overrides={}): """ :param name: :param callback: :param fitextent: :param creatediv: :param loadevent: :param settings_overrides: :return: """ if settings_overrides == '': settings_overrides = {} instance_app_settings = app_settings.copy() # Allow not overidding global app_settings instance_app_settings.update(**settings_overrides) extent = None if instance_app_settings['SPATIAL_EXTENT'] is not None: # Leaflet uses [lat, lng] xmin, ymin, xmax, ymax = instance_app_settings['SPATIAL_EXTENT'] bbox = (ymin, xmin, ymax, xmax) extent = [bbox[:2], bbox[2:4]] djoptions = dict( srid=SRID, extent=extent, fitextent=fitextent, center=instance_app_settings['DEFAULT_CENTER'], zoom=instance_app_settings['DEFAULT_ZOOM'], minzoom=instance_app_settings['MIN_ZOOM'], maxzoom=instance_app_settings['MAX_ZOOM'], layers=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get('TILES')], overlays=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get('OVERLAYS')], attributionprefix=force_text(instance_app_settings.get('ATTRIBUTION_PREFIX'), strings_only=True), scale=instance_app_settings.get('SCALE'), minimap=instance_app_settings.get('MINIMAP'), resetview=instance_app_settings.get('RESET_VIEW'), tilesextent=list(instance_app_settings.get('TILES_EXTENT', [])) ) return { # templatetag options 'name': name, 'loadevents': json.dumps(loadevent.split(), cls=JSONLazyTranslationEncoder), 'creatediv': creatediv, 'callback': callback, # initialization options 'djoptions': json.dumps(djoptions, cls=JSONLazyTranslationEncoder), # settings 'NO_GLOBALS': instance_app_settings.get('NO_GLOBALS'), 'MB_URL': instance_app_settings.get('MB_URL'), }
def leaflet_map(name, callback=None, fitextent=True, creatediv=True, loadevent=app_settings.get('LOADEVENT'), settings_overrides={}): """ :param name: :param callback: :param fitextent: :param creatediv: :param loadevent: :param settings_overrides: :return: """ if settings_overrides == '': settings_overrides = {} instance_app_settings = app_settings.copy() # Allow not overidding global app_settings instance_app_settings.update(**settings_overrides) extent = None if instance_app_settings['SPATIAL_EXTENT'] is not None: # Leaflet uses [lat, lng] xmin, ymin, xmax, ymax = instance_app_settings['SPATIAL_EXTENT'] bbox = (ymin, xmin, ymax, xmax) extent = [bbox[:2], bbox[2:4]] djoptions = dict( srid=SRID, extent=extent, fitextent=fitextent, center=instance_app_settings['DEFAULT_CENTER'], zoom=instance_app_settings['DEFAULT_ZOOM'], minzoom=instance_app_settings['MIN_ZOOM'], maxzoom=instance_app_settings['MAX_ZOOM'], layers=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get('TILES')], overlays=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get('OVERLAYS')], attributionprefix=force_text(instance_app_settings.get('ATTRIBUTION_PREFIX'), strings_only=True), scale=instance_app_settings.get('SCALE'), minimap=instance_app_settings.get('MINIMAP'), resetview=instance_app_settings.get('RESET_VIEW'), tilesextent=list(instance_app_settings.get('TILES_EXTENT', [])) ) return { # templatetag options 'name': name, 'loadevents': json.dumps(loadevent.split(), cls=JSONLazyTranslationEncoder), 'creatediv': creatediv, 'callback': callback, # initialization options 'djoptions': json.dumps(djoptions, cls=JSONLazyTranslationEncoder), # settings 'NO_GLOBALS': instance_app_settings.get('NO_GLOBALS'), }
def leaflet_map( name, callback=None, fitextent=True, creatediv=True, loadevent=app_settings.get("LOADEVENT"), settings_overrides={} ): """ :param name: :param callback: :param fitextent: :param creatediv: :param loadevent: :param settings_overrides: :return: """ if settings_overrides == "": settings_overrides = {} instance_app_settings = app_settings.copy() # Allow not overidding global app_settings instance_app_settings.update(**settings_overrides) extent = None if instance_app_settings["SPATIAL_EXTENT"] is not None: # Leaflet uses [lat, lng] xmin, ymin, xmax, ymax = instance_app_settings["SPATIAL_EXTENT"] bbox = (ymin, xmin, ymax, xmax) extent = [bbox[:2], bbox[2:4]] djoptions = dict( srid=SRID, extent=extent, fitextent=fitextent, center=instance_app_settings["DEFAULT_CENTER"], zoom=instance_app_settings["DEFAULT_ZOOM"], minzoom=instance_app_settings["MIN_ZOOM"], maxzoom=instance_app_settings["MAX_ZOOM"], layers=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get("TILES")], overlays=[(force_text(label), url, attrs) for (label, url, attrs) in instance_app_settings.get("OVERLAYS")], attributionprefix=force_text(instance_app_settings.get("ATTRIBUTION_PREFIX"), strings_only=True), scale=instance_app_settings.get("SCALE"), minimap=instance_app_settings.get("MINIMAP"), resetview=instance_app_settings.get("RESET_VIEW"), tilesextent=list(instance_app_settings.get("TILES_EXTENT", [])), ) return { # templatetag options "name": name, "loadevents": json.dumps(loadevent.split(), cls=JSONLazyTranslationEncoder), "creatediv": creatediv, "callback": callback, # initialization options "djoptions": json.dumps(djoptions, cls=JSONLazyTranslationEncoder), # settings "NO_GLOBALS": instance_app_settings.get("NO_GLOBALS"), }