---
sourceDocument: Yokohama ServiceNow AI Platform 사용자 인터페이스
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/yokohama/platform-user-interface

 Release :

    - yokohama

ft:locale :

    - ko-KR

ft:publication_title :

    - Yokohama ServiceNow AI Platform 사용자 인터페이스

ft:clusterId :

    - platux

bundleId :

    - platux

workflow :

    - Platform


---

# 맵 페이지에 대한 스크립팅

# 맵 페이지에 대한 스크립팅 {#ariaid-title1}

* 릴리스 버전: Yokohama
* 
* 업데이트 날짜 2025년 01월 30일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 10분

맵 페이지 양식의 스크립트 필드를 사용하면 속성 또는 사용자 지정 코드를 사용하여 마커 모양, 표시 정보 등과 같은 맵 특성을 정의할 수 있습니다.

## 맵 항목 속성 스크립팅

다음과 같은 속성을 사용할 수 있습니다.  
주:  
맵에 항목을 생성하려면 map.addItem(glideRecord) 메서드를 사용합니다. 유효한 GlideRecord를 전달합니다.addItem()
{#scripting-for-map-pages__table_a3s_kr5_cr__entry__2}

| 속성 | 설명 |
|-|-|
| name | 식별에 사용되는 이름입니다. |
| 위도 | 주소를 정의하는 경우에는 위도가 필요하지 않습니다. |
| 경도 | 주소를 정의하는 경우에는 경도가 필요하지 않습니다. |
| icon | 마커에 표시할 아이콘의 URL입니다. 사용자 지정 아이콘을 지정하지 않으면 기본 Google 마커가 사용됩니다. |
| icon_width | 아이콘의 너비입니다. 기본값은 32입니다. |
| icon_height | 아이콘의 높이입니다. 기본값은 32입니다. |
| table_name | 마커 아이콘을 클릭할 때 기록이 표시되는 테이블입니다. 속성과 sys_id 함께 사용됩니다. |
| sys_id | 마커 아이콘을 클릭할 때 표시되는 기록의 Sys_id입니다. 속성과 table_name 함께 사용됩니다. |
| view | 마커 아이콘을 클릭할 때 대화 상자에 표시되는 양식 뷰입니다. |
| HTML | 팝업 창에 대한 임의의 HTML 코드입니다. 이 값을 사용하면 대화 상자가 무효화됩니다. |
| marker_label | 선택적 마커 아이콘 레이블 텍스트입니다. |
| label_offset_left | 마커 레이블의 수평 위치를 정의하는 데 사용되는 marker_label 선택적 속성입니다. 기본값은 0입니다. |
| label_offset_top | 마커 레이블의 수직 위치를 정의하는 데 marker_label 사용되는 선택적 속성입니다. 기본값은 0입니다. |
[ ]

{#scripting-for-map-pages__table_a3s_kr5_cr}

## 스마트폰용 사용자 지정 맵 페이지 동작 스크립팅 {#scripting-for-map-pages__section_sx4_jtw_j1b}

스마트폰에서 맵 페이지에 액세스하려는 경우 변수를 isMobile 사용하여 사용자 지정 스마트폰 인터페이스 동작을 설정할 수 있습니다. 이 변수를 사용하여 isMobile 스마트폰 뷰의 맵에 대한 사용자 지정 동작을 설정할 수 있습니다. 예를 들어, 예일 때 isMobile 및 icon_height 속성에 대해 icon_width 서로 다른 값을 설정할 수 있습니다.

## 기본 맵 페이지 스크립트 {#scripting-for-map-pages__section_q5n_ytw_j1b}

이 스크립트는 모든 활성 상태의 중요한 인시던트 위치를 표시합니다.

    //setup new GlideRecord query on the incident table
    var now_GR = new GlideRecord("incident");
    //add condition for priority 1
    gr.addQuery('priority', '1');
    //add condition for active incidents
    gr.addActiveQuery();
    //execute the query
    gr.query();
     
    //loop through the list of incidents returned by the query
    while (gr.next()) {
     
     //create a new map item to display - linked to the current incident record
     var item = map.addItem(now_GR);
     //add the latitude value from the incident's location
     item.latitude = gr.location.latitude;
     //add the longitude value from the incident's location
     item.longitude = gr.location.longitude;
     //link to the icon image
     item.icon = "http://maps.google.com/mapfiles/kml/pal3/icon51.png";
     //set the icon size
     item.icon_width = "16";
     item.icon_height = "16";
    }

## isMobile 맵 페이지 스크립트 {#scripting-for-map-pages__section_ldd_v5w_j1b}

이 스크립트는 스마트폰 사용자에 대한 사용자 지정 설정과 함께 모든 활성 상태의 중요 인시던트 위치를 표시합니다.

    //setup new GlideRecord query on the incident table
    var now_GR = new GlideRecord("incident");
    //add condition for priority 1
    gr.addQuery('priority', '1');
    //add condition for active incidents
    gr.addActiveQuery();
    //execute the query
    gr.query();
     
    //loop through the list of incidents returned by the query
    while (gr.next()) {
     
     //create a new map item to display - linked to the current incident record
     var item = map.addItem(now_GR);
     //add the latitude value from the incident's location
     item.latitude = gr.location.latitude;
     //add the longitude value from the incident's location
     item.longitude = gr.location.longitude;
     //link to the icon image
     item.icon = "http://maps.google.com/mapfiles/kml/pal3/icon51.png";
     
     //set the icon size (use smaller icons for smartphone users)
     if (isMobile) {
       item.icon_width = "12";
       item.icon_height = "12";
     }
     else { 
       item.icon_width = "16";
       item.icon_height = "16";
     }
    }

## 고급 맵 페이지 스크립트 {#scripting-for-map-pages__section_blc_bvw_j1b}

이 스크립트는 위치별로 열린 인시던트 수를 표시합니다. 위치의 미해결 인시던트 수에 따라 아이콘 크기가 달라집니다. html 매개변수를 사용하면 위치 이름과 인시던트 수는 물론 관련 인시던트 목록에 대한 링크도 표시됩니다.

    //get the instances url so we can link back to it
    var uri = gs.getProperty("glide.servlet.uri");
    //create an aggregate query on the incident table
    var count = new GlideAggregate('incident');
    //set condition for active incidents
    count.addQuery('active', 'true');
    //set aggregate field to location to get count by location
    count.addAggregate('COUNT', 'location');
    //execute the query
    count.query();
     
    //loop through the results
    while (count.next()) {
     
     //get the current record's location
     var loc = count.location;
     //get the count of incidents for this location
     var locCount = count.getAggregate('COUNT', 'location');
     //only display location is there are active incidents
     if (locCount > 0) {
     //create new new map item for this location
     var item = map.addItem(count);
     //set lat/long from the location record
     item.latitude = loc.latitude;
     item.longitude = loc.longitude;
     //build the link to the list of incidents for the location
     var link = 'href=' + uri + 'incident_list.do?sysparm_query=active%3Dtrue^location%3D' + loc;
     //build the html value to be displayed when you click the map icon
     item.html='<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ')</a>';
     //link to the icon image
     item.icon = "http://maps.google.com/mapfiles/kml/pal3/icon51.png";
     //set the size of the icon based on the number of active incidents
     if (locCount < 5) {
     item.icon_width = "12";
     item.icon_height = "12";
     }
     else if (locCount < 15) {
     item.icon_width = "16";
     item.icon_height = "16";
     }
     else {
     item.icon_width = "32";
     item.icon_height = "32";
     }
     }
    }

## 맵 페이지 마커 레이블 스크립트 {#scripting-for-map-pages__section_nyt_mvw_j1b}

마커 레이블을 사용하면 마커에 동적 텍스트를 추가할 수 있습니다. 이 예에서는 각 위치의 활성 인시던트 수를 표시합니다. 그림 1. 맵 마커 레이블

    //get the instances url so we can link back to it
    var uri = gs.getProperty("glide.servlet.uri");
    //create an aggregate query on the incident table
    var count = new GlideAggregate('incident');
    //set condition for active incidents
    count.addQuery('active', 'true');
    //set aggregate field to location to get count by location
    count.addAggregate('COUNT', 'location');
    //execute the query
    count.query();
     
    //loop through the results
    while (count.next()) {
     
     //get the current record's location
     var loc = count.location;
     //get the count of incidents for this location
     var locCount = count.getAggregate('COUNT', 'location');
     //only display location is there are active incidents
     if (locCount > 0) {
     //create new new map item for this location
     var item = map.addItem(count);
     //set lat/long from the location record
     item.latitude = loc.latitude;
     item.longitude = loc.longitude; 
     
     //create a marker label with the count
     item.marker_label = locCount;
     //define label offset for proper position
     item.label_offset_left = -4;
     item.label_offset_top = -20;
     
     //option to define table and record for label hyperlink
     //setting table and sys_id will override the use of html parameter
     //item.table = 'cmn_location';
     //item.sys_id = loc;
     
     //build the link to the list of incidents for the location
     var link = 'href=' + uri + 'incident_list.do?sysparm_query=active%3Dtrue^location%3D' + loc;
     //build the html value to be displayed when you click the map icon
     item.html='<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ')</a>';
     
     //link to the icon image
     item.icon = "images/red_marker.png";
     //set the size of the icon based on the number of active incidents
     item.icon_width = 24;
     item.icon_height = 24;
     
     }
    }

**관련 태스크**   

* [Google Maps API 설정](https://servicenow-prod.fluidtopics.net/EWYZ34q72A2cuZwSNxUbzA "비즈니스용 Maps API 라이센스 또는 Google Maps JavaScript API 키의 Google 적절한 항목을 사용하여 지리적 위치 기능을 활성화합니다.")
* [맵 페이지 생성](https://servicenow-prod.fluidtopics.net/my6de~gPdkzylxg9BrukCw "인스턴스가 ServiceNow 여러 기본 맵 페이지를 제공합니다. 이 페이지에 설명된 스크립트 예시를 사용하여 사용자 지정 맵 페이지를 생성할 수도 있습니다.")
* [맵 페이지 모듈 생성](https://servicenow-prod.fluidtopics.net/AS49WlIvWSVQX5zk_T4rBA "데스크톱 또는 스마트폰 사용자가 맵 페이지를 표시할 수 있도록 새 애플리케이션 모듈을 Google 만들 수 있습니다.")
* [고급 맵 페이지 생성](https://servicenow-prod.fluidtopics.net/v25nSpaCUm1H8PpHpIalmg "고급 구성을 사용하여 스크립팅 없이 맵 페이지를 설정합니다.")
* [맵 애플리케이션 범위 설정](https://servicenow-prod.fluidtopics.net/1j0_FFlIO7ELzNn0GU_CmA "맵 애플리케이션 범위를 활성화하여 맵 페이지 구성을 수정할 수 있는 애플리케이션을 지정합니다.")
* [스마트폰 맵 페이지 모듈 만들기](https://servicenow-prod.fluidtopics.net/Z3QMZCj3Vkr_ryV9unZr0g "맵 페이지에 직접 연결되는 사용자 지정 스마트폰 모듈을 만들 수 있습니다.")

