{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":796,"path":"api-reference/server-api-reference/GlideGeopointGlobalAPI.md","title":"GlideGeoPoint - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideGeoPoint- Global\n\nThe GlideGeoPoint API enables you to get and set geopoint data type values in a table.\n\nThis API is available by default. The geopoint data type allows you to store a latitude and longitude values in a single field within a table. Using the GlideGeoPoint API, you can instantiate new GlideGeoPoint objects, create new geopoints for a specific table, or retrieve single latitude, longitude or geotype values. For additional information on how to implement specific use cases like inserting new records using a geopoint, computing distances between geopoint locations, or querying for nearby geopoint locations, see [GlideGeoPoint Developer Guide](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/geopoint-dev-guide.md).\n\nKey aspects of the geotype data type are:\n\n-   It consists of a pair of decimal numbers representing longitude and latitude values.\n-   The range for longitude is \\(-180, 180\\]. Any value outside this range is normalized to the equivalent value inside this range.\n-   The range for latitude is \\[-90, 90\\]. Any value outside this range is normalized to the equivalent value inside this range.\n-   Geopoint values are always accepted as input and display as a comma-separated pair: “longitude,latitude”. Parentheses may optionally surround the expression.\n-   Both longitude and latitude values are stored up to 6 decimal places of precision.\n\n**Note:** GlideGeoPoint API values are always listed in longitude, latitude order.\n\nThe examples on this page assume that a custom table is pre-populated with fields containing the geopoint field type. For more information about this data type, see [Geo point field type](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/geo-point-field-type.md) and [Function field](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/platform-support-functions.md).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## GlideGeoPoint - GlideGeoPoint\\(\\)\n\nInstantiates a GlideGeoPoint object. The GlideGeoPoint object adds semantic awareness to longitude and latitude values that are otherwise stored as strings.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| ||\n\nThe following example shows how to initialize a new GlideGeoPoint object as a null value.\n\n```\nvar gp = new GlideGeoPoint();\n```\n\n## GlideGeoPoint - GlideGeoPoint\\(String longitude, String latitude\\)\n\nInstantiates the GlideGeoPoint object according to provided longitude and latitude values.\n\n|Name|Type|Description|\n|----|----|-----------|\n|longitude|String|The longitude coordinate of the geopoint.|\n|latitude|String|The latitude coordinate of the geopoint.|\n\n|Type|Description|\n|----|-----------|\n|geopoint|The resultant GlideGeoPoint object.|\n\nThe following example shows how providing longitude and latitude values initializes the object accordingly.\n\n```\n// Providing longitude and latitude values initializes the object accordingly \nvar gp = new GlideGeoPoint(10.123, 25.987);  \ngs.info(\"geopoint: \" + gp);\n```\n\nOutput:\n\n```\ngeopoint: 10.123000,25.987000\n```\n\n## GlideGeoPoint - GlideGeoPoint\\(Object geoPoint\\)\n\nCopies longitude and latitude points values to instantiate a new GlideGeoPoint object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|geoPoint|Object|The geopoint instance that you want copy.|\n\n|Type|Description|\n|----|-----------|\n|geopoint|The resultant GlideGeoPoint object.|\n\nThe following example shows how to copy longitude and latitude values to instantiate a new GlideGeoPoint object.\n\n```\nvar gp = new GlideGeoPoint(135, -64);\nvar gpCopy = new GlideGeoPoint(gp); \ngs.info(\"geopoint: \" + gpCopy);\n```\n\nOutput:\n\n```\ngeopoint: 135,-64\n```\n\n## GlideGeoPoint - getDisplayValue\\(\\)\n\nReturns the geopoint of the current user in a user-friendly format.\n\nThe getDisplayValue\\(\\) method returns a single geopoint value. For information about how to retrieve all geopoint values from a specific table, see [GlideGeoPoint Developer Guide](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/geopoint-dev-guide.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The value of the longitude and latitude coordinates set in the object.|\n\n```\nvar gp = new GlideGeoPoint(); \ngp.setValue(76.25, 49.75);      \ngs.info(\"geopoint: \" + gp); \ngs.info(\"getDisplayValue(): \" + gp.getDisplayValue());\n```\n\nOutput:\n\n```\ngeopoint: 76.250000,49.750000 \ngetDisplayValue(): (76.250000, 49.750000)\n```\n\n## GlideGeoPoint - getGeoPoint\\(String geo\\_point\\_field\\_name\\)\n\nReturns a list of geo point coordinate values for a given field name of type geo point.\n\n<table id=\"table_bz4_jsl_5bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ngeo\\_point\\_field\\_name\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the geo point field.**Note:** You can also locate field names under dictionary elements defined on a table to see associated fields of geo point type.\n\nTable: Dictionary Entry \\[sys\\_dictionary\\]\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Resultant GlideGeoPoint object.|\n\nIn the following example, 'test\\_table' is a table which contains the 'geo\\_point' field of geo point type. The test\\_table has one record populated in the geo\\_point column with a value of \\(-30.560000,-54.330000\\). The example code returns the latitude and longitude coordinates and display value of the record in geo\\_point column.\n\n```\nvar gr_Test = new GlideRecord('test_table');\ngr_Test.query();\ngr_Test.next();\nvar gp = gr_Test.getGeoPoint('geo_point');\ngs.info(\"getLatitude(): \" + gp.getLatitude());\ngs.info(\"getLongitude(): \" + gp.getLongitude());\ngs.info(\"getDisplayValue(): \" + gp.getDisplayValue());\n```\n\nOutput:\n\n```\ngetLatitude(): -54.33\ngetLongitude(): -30.560000000000002 \ngetDisplayValue(): (-30.560000, -54.330000)\n```\n\n## GlideGeoPoint - getLatitude\\(\\)\n\nReturns the latitude value of the GlideGeoPoint object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The latitude value of the GlideGeoPoint object.|\n\n```\nvar gp = new GlideGeoPoint(); \ngp.setValue(76.25, 49.75);      \n\ngs.info(\"geopoint: \" + gp); \ngs.info(\"getLatitude(): \" + gp.getLatitude());\n```\n\nOutput:\n\n```\ngeopoint: 76.250000,49.750000 \ngetLatitude(): 49.75\n```\n\n## GlideGeoPoint - getLongitude\\(\\)\n\nReturns the longitude value of the GlideGeoPoint object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The longitude value of the GlideGeoPoint object.|\n\n```\nvar gp = new GlideGeoPoint(); \ngp.setValue(76.25, 49.75);      \ngs.info(\"geopoint: \" + gp);  \ngs.info(\"getLongitude(): \" + gp.getLongitude());\n```\n\nOutput:\n\n```\ngeopoint: 76.250000,49.750000 \n getLongitude(): 76.25\n```\n\n## GlideGeoPoint - getValue\\(\\)\n\nReturns a string containing the programmatic longitude and latitude value of the current GlideGeoPoint object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The longitude and latitude value of the current GlideGeoPoint object.|\n\n```\n var gp = new GlideGeoPoint(); \ngp.setValue(76.25, 49.75);      \ngs.info(\"geopoint: \" + gp);\ngs.info(\"getValue(): \" + gp.getValue());\n```\n\nOutput:\n\n```\ngeopoint: 76.250000,49.750000\ngetValue(): 76.250000,49.750000\n```\n\n## GlideGeoPoint - setValue\\(String longitude, String latitude\\)\n\nSets the longitude and latitude values of the geopoint.\n\n|Name|Type|Description|\n|----|----|-----------|\n|longitude|String|The longitudinal coordinate of the geopoint.|\n|latitude|String|The latitude coordinate of the geopoint.|\n\n|Type|Description|\n|----|-----------|\n|String|The longitude and latitude value set on the GlideGeoPoint object.|\n\n```\nvar gp = new GlideGeoPoint(); \ngp.setValue(\"-28.48,38.91\");      \ngs.info(\"geopoint: \" + gp);\n```\n\nOutput:\n\n```\ngeopoint: -28.480000,38.910000\n```\n\n## GlideGeoPoint - setValue\\(String value\\)\n\nSets the longitude and latitude values of the geopoint using a single comma-delimited value.\n\n|Name|Type|Description|\n|----|----|-----------|\n|value|String|A comma-delimited value containing longitude and latitude points respectively.|\n\n|Type|Description|\n|----|-----------|\n|String|The longitude and latitude value set on the GlideGeoPoint object.|\n\nThe following example shows how to set the longitude and latitude values using a single string.\n\n```\nvar gp = new GlideGeoPoint();\ngp.setValue(23.4, 56.7);\n```\n\nOutput:\n\n```\ngeopoint: -23.400000,56.700000\n```\n\n"}}