This project through the Socket communication access to the longitude and latitude data of terminal transmission, need to be done by calling the baidu map data real-time calibration, however, baidu map API call is in MFC HTML file using Java script to write a file, in js for the creation of the map and according to the longitude and latitude of real-time calibration, my question is: how will the Socket communication mode to obtain the latitude and longitude data (this section is written by c + +) is passed to the HTML js?
For you help, the younger brother grateful,
CodePudding user response:
I don't know what do you want from the server or from the client to add, but that I have used in two ways, the service side I am by the latitude and longitude and device ID write to share files with a line of string, then the server backstage regularly read this file to get the latest GPS data, the client is passing data through a com component sends messages to the client, the parameter is the ID string contains latitude and longitude and equipment, also made a program to help a friend a few days ago, replace the client interface of words and images, IE I was achieved by BHO, you can use the BHO javascript calls to the current Internet explorer document, the hope can help you,CodePudding user response:
Client to insert the ie control, access to baidu map, called directly baidu map API,CodePudding user response:
Through the webbrowser - pass data to jsCodePudding user response:
http://blog.csdn.net/charlessimonyi/article/details/18447471CodePudding user response:
http://bbs.csdn.net/topics/392320388
CWebBrowser20 m_WebBrowser;
IHTMLDocument2 * m_pIHTMLDoc;
M_WebBrowser. Navigate2 (& amp; CComVariant (_T (" about: blank ")), NULL, NULL, NULL, NULL);
M_WebBrowser. Put_Silent (TRUE);
LoadHTML (" HTML code ", length);
//get the Document refers to the clock
CComPtrPDocument=m_WebBrowser. Get_Document ();
If (pDocument)
{
If (m_pIHTMLDoc)
{
M_pIHTMLDoc - & gt; Release ();
M_pIHTMLDoc=NULL;
}
PDocument - & gt; QueryInterface (IID_IHTMLDocument2, (void * *) & amp; M_pIHTMLDoc);
}
//JS function called
If (m_pIHTMLDoc)
{
CComPtrIf (S_OK==m_pIHTMLDoc - & gt; Get_parentWindow (& amp; PHTMLWindow) & amp; & PHTMLWindow)
{
The VARIANT ret.
PHTMLWindow - & gt; ExecScript (CComBSTR (" JS function "), CComBSTR (" JScript "), & amp; Ret);
}
}
//================================================
//load the HTML code to the component
Void LoadHTML (LPVOID pData, int nLen)
{
CComPtrSpDoc (m_WebBrowser get_Document ());
If (NULL==spDoc | | NULL==pData)
{
return;
}
//get IPersistStreamInit pointer
CComQIPtrIf (NULL==spPSI)
{
return;
}
//the application memory, copy the HTML string
LPSTR lpMemory=(LPSTR) : : GlobalAlloc (GPTR, nLen + 1);
ZeroMemory (lpMemory nLen + 1);
Memcpy (lpMemory, pData, nLen);
//convert the memory to stream object pointer
CComPtrSpStream;
Retrieves the hr=CreateStreamOnHGlobal (lpMemory, TRUE, & amp; SpStream);
If (FAILED (hr) | |! SpStream)
{
return;
}
//after the initialization, loading according to
Hr=spPSI - & gt; InitNew ();
If (FAILED (hr))
{
return;
}
Hr=spPSI - & gt; Load (spStream);
If (FAILED (hr))
{
return;
}
}
CodePudding user response:
http://bbs.csdn.net/topics/392320388To the code, direct COPY down to save
CodePudding user response:
Baidu map code, will give you the data through the above code is loaded into the control, can realize the transition of positioning, js function call
<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
<meta name="viewport" content="initial - scale=1.0, user - scalable=no"/& gt;
<style type="text/css">
Body, HTML, # baiduMaps {width: 100%; height: 100%; overflow: hidden; margin:0; The font-family: "Microsoft jas black"; }
# r - result {width: 100%; font-size:14px; }
</style>Asynchronous loading map & lt;/title>
Longitude: & lt; Input the id="longitude" type="text" style="width: 100 px; Margin - right: 10 px;"/& gt;
Latitude: & lt; Input the id="latitude" type="text" style="width: 100 px; Margin - right: 10 px;"/& gt;