Arcgis:通过JS应用程序进行身份验证

时间:2018-05-30 08:22:18

标签: javascript arcgis

我正在使用JavaScript编写程序,该程序通过ArcGIS REST API连接到本地ArcGIS服务器并加载地图。

获取服务的网址是

let xmlhttp = new XMLHttpRequest();
xmlhttp.withCredentials = true;
let url = "http://domain/arcgis/rest/services/" + serviceName +"/MapServer/" + layer_id +  "/query?f=json&where=1%3D1&returnGeometry=false&outFields=*";

我可以通过API获取令牌。问题是,我无法在cookie中设置它,因为浏览器拒绝以编程方式编写另一个域。

有人建议解决方法吗?

1 个答案:

答案 0 :(得分:1)

您可以将class parReader { public: parReader(std::string dirname, std::vector< cv::Mat > & lst); private: size_t filesIdx; HANDLE hFilesMux,hImgListMux; std::vector<cv::String> files; std::vector<cv::Mat> img_lst; static void readImgs(parReader *nm); const char *getNext(); void push_back(cv::Mat &img); }; parReader::parReader(std::string dirname, std::vector<cv::Mat> & lst) :img_lst(lst), filesIdx(0),hFilesMux(NULL),hImgListMux(NULL) { hFilesMux = CreateMutex(NULL, 0, NULL); hImgListMux = CreateMutex(NULL, 0, NULL); cv::glob(dirname, files); std::thread pr1(readImgs, this); std::thread pr2(readImgs, this); std::thread pr3(readImgs, this); std::thread pr4(readImgs, this); pr1.join(); pr2.join(); pr3.join(); pr4.join(); CloseHandle(hFilesMux); CloseHandle(hImgListMux); } const char *parReader::getNext() { const char *res = NULL; WaitForSingleObject(hFilesMux, INFINITE); if (filesIdx < files.size()) res = files[filesIdx++].c_str(); ReleaseMutex(hFilesMux); return res; } void parReader::push_back(cv::Mat &img) { WaitForSingleObject(hImgListMux, INFINITE); img_lst.push_back(img); ReleaseMutex(hImgListMux); } void parReader::readImgs(parReader *nm) { while (true) { const char *fn = nm->getNext(); if (fn == NULL) break; cv::Mat img = cv::imread(fn); if (img.empty()) // treci peste daca este imagine invalida { std::cout << fn << " is invalid!" << std::endl; continue; } nm->push_back(img); } } int main() { std::vector<cv::Mat> imgList; parReader mgr("*.png",imgList); } 添加到您的网址,以便获得:

&token=abcd1234