Advertisement
hecrus

Map GetItems

Jan 27th, 2022
1,290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.96 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[crud_testMap_getItems]
  2.     @filters CRUDFilterParameter READONLY,
  3.     @sort sql_variant,
  4.     @direction nvarchar(8),
  5.     @page int,
  6.     @pageSize int,
  7.     @username nvarchar(32)
  8. AS
  9. BEGIN
  10.     declare   @result TABLE (id int, lat nvarchar(32), lng nvarchar(32), description nvarchar(max),
  11.                              tooltip nvarchar(128), radius int, canDrag bit, fillColor nvarchar(256), strokeWeight int, strokeColor nvarchar(max),
  12.                             label nvarchar(128), labelClass nvarchar(256), icon nvarchar(128)
  13.                             )
  14.  
  15.     declare @langID int
  16.     select @langID = try_cast(Value as int) from @filters where [Key] = 'langID'
  17.  
  18.  
  19.     declare @filterCity int
  20.     select @filterCity = Value from @filters where [Key] = 'tooltip'
  21.    
  22.     insert into @result
  23.     select id,
  24.            lat,
  25.            lng,
  26.             (select top 1 name  from as_geo_regions where id = cityID) + ' ' + address description,
  27.               address as tooltip,
  28.            500 radius,
  29.            1 canDrag,
  30.            '#0000ff' fillColor,
  31.            10 strokeWeight,
  32.            '#00aadd' strokeColor,
  33.            'Point '+ cast(id as nvarchar) label,
  34.            'btn btn-info p-0 mb-5 font-weight-bold text-white' labelClass,
  35.            '' icon
  36.     from tst_addresses
  37.     where isnull(@filterCity,0)=0 or cityID in (select id from as_geo_regions where id = @filterCity)
  38. /*          
  39.     insert into @result
  40.     select 1 id,
  41.         '43.5868685' lat,
  42.         '39.7299474' lng,
  43.         '<div class="as-form" data-code="captureContact"></div>' description,
  44.         'Подсказка для элемента' tooltip,
  45.         500 radius,
  46.         0 canDrag
  47.    
  48.     insert into @result
  49.     select 2 id,
  50.         '42.5868685' lat,
  51.         '39.1299474' lng,
  52.         'Вторая точка' description,
  53.         'Подсказка для второй точки' tooltip,
  54.         500 radius,
  55.         0 canDrag
  56.        
  57.     insert into @result
  58.     select 3 id,
  59.         '55.753960' lat,
  60.         '37.620393' lng,
  61.         'Еще одна точка' description,
  62.         'Подсказка для этой точки' tooltip,
  63.         500 radius,
  64.         0 canDrag
  65.  */  
  66.    
  67.     -- 1 SELECT - сами данные    
  68.     select * from @result
  69.     order by  radius
  70.        
  71.     OFFSET @PageSize * (@Page - 1) ROWS
  72.     FETCH NEXT @PageSize ROWS ONLY;
  73.    
  74.     -- 2 SELECT - кол-во в таблице
  75.     select count(*) from @result   
  76.  
  77.     declare @isAdmin int = 0
  78.     select @isAdmin = 1 from sec_getUserRoles(@username) where role = 'admin'
  79.  
  80.  
  81.     -- 3 SELECT Дополнительные настройки таблицы
  82.     Select 'map' ViewType,
  83.         1 MapShowUserLocation,
  84.         '/Controls/Resource/GetFile?code=userPhoto&user='+@username+'&thumb=1' MapUserImageUrl,
  85.         1 MapShowAllRegions,
  86.         1 MapShowLocationInRange,
  87.         '{         
  88.             "fitBound": 0,
  89.             "zoom":7,
  90.            "mapCenter": {"lat":55.760533, "lng": 37.487028}
  91.        }' MapOptions,
  92.         iif(@langID=1, 'Map with points', 'Вывод точек на карте') title,
  93.         iif(@langID=1, 'An example of a map display with some points found, each point has the ability to place a shape or some kind of description', 'Пример вывода карты с некоторыми найденными точками, у каждой точки есть возможность разместить форму или некое описание') titleTooltip,
  94.        
  95.         case when isnull(@isAdmin,0)=0 then '' else '<a href="/tst-addAddress" class="btn btn-primary mb-1"><i class="fas fa-plus"></i> '+iif(@langID=1, 'Add point', 'Добавить точку')+'</a>' end as ToolbarAdditional,
  96.         1 InstantFilter
  97.     -- 4 SELECT Данные для подвала страницы или данные для Ганта/Канбана (если установлен ViewType в 3 SELECT)
  98. END
  99.  
  100. --admin 29.04.2021 12:50:08
  101. --ru 02.06.2021 15:16:16
  102. --ru 15.01.2022 20:03:07
  103. --ru 27.01.2022 10:29:00
  104. --ru 27.01.2022 10:33:50
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement