Map Library
Retrieve a JavaScript SPL Maps Library.
Usage:
You must use an access token to make an authenticated call to our system. Access token are generated based on your subscription type. To get your access token please refer to “Your Subscriptions” section available on profile page.
Limits for calls to API
Our system doesn’t apply any limits on number of requests you can make for a particular API. But there are limits defined for total number of calls you can make per min and in one week.
API Request
Input Parameters
Field | Description |
---|---|
api_key | Access token to authenticate you as a valid user of the system. Please refer to profile section to get your subscription key. |
Requested URL
https://apina.address.gov.sa/splmapsjs/splmaps.min.js?api_key=<apikey>
Response
Default Response Returned
By default, the following stream of JS is returned in the response.
Sample Response
JSON
function SPLMaps() {
var _this = this;
this.popup = false;
this.map;
this.view;
this.graphicsLayer = {};
this.Graphic = {};
this.sources = [
{ type: 'css', url: "https://js.arcgis.com/4.25/esri/themes/light/main.css"
},
{type: 'javascript', url: "https://js.arcgis.com/4.25/"
}
];
this.identifyToken;
this.services = {
IdentifyService: "https://geoapis.address.gov.sa/Identify",
vmapserviceAr: "https://vmaps.address.gov.sa/agserver/rest/services/Hosted/BaseMapAr/VectorTileServer",
vmapserviceEn: "https://vmaps.address.gov.sa/agserver/rest/services/Hosted/BaseMapEn/VectorTileServer"
};
this.appendDependencies = () => {
for (i = 0; i < _this.sources.length; i++) {
var headTag = document.getElementsByTagName('head')[
0
];
var includeTag;
if (_this.sources[i
].type == 'javascript') {
includeTag = document.createElement('script');
includeTag.setAttribute('type', 'text/javascript');
includeTag.setAttribute('src', _this.sources[i
].url);
} …… stream of JS Code
Common Errors
If there's an error with your API call, the API will return a HTTP status code along with a message detailing the error.
Code | Description | Solution |
---|---|---|
401 | "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key." | Ensure that a valid access token is being used in your API call By catching 401 unauthorized exceptions in all your calls you'll provide the coverage you need in your application to handle expired tokens. It's good practice to design and develop your application in anticipation that with any request you could potentially have an invalid access token. |
404 | Page not found | The endpoint or resource your application is trying to reach doesn't exist |
405 | Method Not Allowed. | |
500 | Internal Service Error | There was an application error on our server. Usually your request is valid but needs to be made at a later time. |