通过浏览器来获取用户当前位置。基于此特性可以开发基于位置的服务应用。在获取地理位置信息前,首先浏览器都会向用户询问是否愿意共享其位置信息,待用户同意后才能使用。
Html5获取地理位置信息是通过Geolocation API提供,使用其getCurrentPosition方法,此方法中有三个参数,分别是成功获取到地理位置信息时所执行的回调函数,失败时所执行的回调函数和可选属性配置项。
/ Copyright (c) MediaAreanet SARL All Rights Reserved
Use of this source code is governed by a BSD-style license that can
be found in the Licensehtml file in the root of the source tree
/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Example for MediaInfoLib
// Command line version
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifdef MEDIAINFO_LIBRARY
#include "MediaInfo/MediaInfoh" //Staticly-loaded library (lib or a or so)
#define MediaInfoNameSpace MediaInfoLib;
#else //MEDIAINFO_LIBRARY
#include "MediaInfoDLL/MediaInfoDLLh" //Dynamicly-loaded library (dll or so)
#define MediaInfoNameSpace MediaInfoDLL;
#endif //MEDIAINFO_LIBRARY
#include <iostream>
#include <iomanip>
using namespace MediaInfoNameSpace;
#ifdef __MINGW32__
#ifdef _UNICODE
#define _itot _itow
#else //_UNICODE
#define _itot itoa
#endif //_UNICODE
#endif //__MINGW32
int main (int /argc/, Char /argv[]/)
{
//Information about MediaInfo
MediaInfo MI;
String To_Display=MIOption(__T("Info_Version"), __T("0713;MediaInfoDLL_Example_MSVC;0713"))c_str();
To_Display += __T("\r\n\r\nInfo_Parameters\r\n");
To_Display += MIOption(__T("Info_Parameters"))c_str();
To_Display += __T("\r\n\r\nInfo_Codecs\r\n");
To_Display += MIOption(__T("Info_Codecs"))c_str();
//An example of how to use the library
To_Display += __T("\r\n\r\nOpen\r\n");
MIOpen(__T("Exampleogg"));
To_Display += __T("\r\n\r\nInform with Complete=false\r\n");
MIOption(__T("Complete"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nInform with Complete=true\r\n");
MIOption(__T("Complete"), __T("1"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nCustom Inform\r\n");
MIOption(__T("Inform"), __T("General;Example : FileSize=%FileSize%"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n");
To_Display += MIGet(Stream_General, 0, __T("FileSize"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nGetI with Stream=General and Parameter=46\r\n");
To_Display += MIGet(Stream_General, 0, 46, Info_Text)c_str();
To_Display += __T("\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n");
#ifdef __MINGW32__
Char C1=new Char[33];
_itot (MICount_Get(Stream_Audio), C1, 10);
To_Display +=C1;
delete[] C1;
#else
toStringStream SS;
SS << std::setbase(10) << MICount_Get(Stream_Audio);
To_Display += SSstr();
#endif
To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n");
To_Display += MIGet(Stream_General, 0, __T("AudioCount"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n");
To_Display += MIGet(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nClose\r\n");
MIClose();
#ifdef _UNICODE
std::wcout << To_Display;
#else
std::cout << To_Display;
#endif
return 0;
}
//
// By buffer example
//
/
//---------------------------------------------------------------------------
//Note: you can replace file operations by your own buffer management class
#include <stdioh>
int main (int argc, Char argv[])
{
//From: preparing an example file for reading
FILE F=fopen("Exampleogg", "rb"); //You can use something else than a file
if (F==0)
return 1;
//From: preparing a memory buffer for reading
unsigned char From_Buffer=new unsigned char[7188]; //Note: you can do your own buffer
size_t From_Buffer_Size; //The size of the read file buffer
//From: retrieving file size
fseek(F, 0, SEEK_END);
long F_Size=ftell(F);
fseek(F, 0, SEEK_SET);
//Initializing MediaInfo
MediaInfo MI;
//Preparing to fill MediaInfo with a buffer
MIOpen_Buffer_Init(F_Size, 0);
//The parsing loop
do
{
//Reading data somewhere, do what you want for this
From_Buffer_Size=fread(From_Buffer, 1, 7188, F);
//Sending the buffer to MediaInfo
size_t Status=MIOpen_Buffer_Continue(From_Buffer, From_Buffer_Size);
if (Status&0x08) //Bit3=Finished
break;
//Testing if there is a MediaInfo request to go elsewhere
if (MIOpen_Buffer_Continue_GoTo_Get()!=(MediaInfo_int64u)-1)
{
fseek(F, (long)MIOpen_Buffer_Continue_GoTo_Get(), SEEK_SET); //Position the file
MIOpen_Buffer_Init(F_Size, ftell(F)); //Informing MediaInfo we have seek
}
}
while (From_Buffer_Size>0);
//Finalizing
MIOpen_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work
//Get() example
String To_Display=MIGet(Stream_General, 0, __T("Format"));
#ifdef _UNICODE
std::wcout << To_Display;
#else
std::cout << To_Display;
#endif
}
/
1、 创建文件(CreateFile),如下:HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);参数解析:lpFileName:需要创建或者打开的文件名字dwDesiredAccess:文件的打开方式,GENERIC_READ(只读), GENERIC_WRITE(只写), GENERIC_READ GENERIC_WRITE(读写)dwShareMode:文件的共享方式,如:FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITElpSecurityAttributes:文件的安全属性,通常为空dwCreationDisposition:文件的访问方式,如:CREATE_ALWAYS, CREATE_NEW, OPEN_ALWAYS, OPEN_EXISTING, or TRUNCATE_EXISTING(只能是其中一种,不能组合使用)dwFlagsAndAttributes:文件属性和标志hTemplateFile:模板文件句柄 2、 创建文件内存映射(CreateFileMapping),如下:HANDLE WINAPI CreateFileMapping( _In_ HANDLE hFile, _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, _In_ DWORD flProtect, _In_ DWORD dwMaximumSizeHigh, _In_ DWORD dwMaximumSizeLow, _In_opt_ LPCTSTR lpName); 参数解析: hFile:需要创建文件内存映射的文件句柄lpAttributes:安全属性指针flProtect:文件内存映射访问模式dwMaximumSizeHigh:内存映射大小的高32位dwMaximumSizeLow:内存映射大小的低32位lpName:内存映射的名字 3、 获得系统分配粒度(GetSystemInfo),如下:void WINAPI GetSystemInfo( _Out_ LPSYSTEM_INFO lpSystemInfo) 参数解析:lpSystemInfo:SYSTEM_INFO结构指针 4、 文件内存映射视图(MapViewOfFile)LPVOID WINAPI MapViewOfFile( _In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, _In_ DWORD dwFileOffsetHigh, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap); 参数解析:hFileMappingObject:文件内存映射句柄dwDesiredAccess:访问方式,如FILE_MAP_ALL_ACCESS、FILE_MAP_COPY等dwFileOffsetHigh:文件偏移大小高位dwFileOffsetLow:文件偏移大小低位注意:文件偏移必须是系统粒度的整数倍dwNumberOfBytesToMap:映射多少数据进视图 5、 撤销文件内存映射视图(UnmapViewOfFile)BOOL WINAPI UnmapViewOfFile( _In_ LPCVOID lpBaseAddress); 参数解析:lpBaseAddress:文件视图指针三、使用方法 1、 使用CreateFile创建/打开一文件,这个文件对象标识了磁盘上将要用作内存映射文件的文件。 2、 使用CreateFileMapping函数来创建一个文件映射内核对象,告诉系统文件的尺寸以及访问文件的方式。 3、 使用MapViewOfFile函数负责通过系统的管理而将文件映射对象的全部或部分映射到进程地址空间。 4、 通过UnmapViewOfFile完成从进程的地址空间撤消文件数据的映像、通过CloseHandle关闭前面创建的文件映射对象和文件对象。四、使用举例 功能:在一个大文件(文件名BigFiletxt)中,查找一字符串”End”。实现根据字符串"End"将文件截断的功能。 代码工程名IOTestsln: 详细代码见BigFileFunh、BigFileFuncpp 调用代码见IOTestcpp中_tmain函数
以上就是关于java怎么调用地图获取地理位置信息全部的内容,包括:java怎么调用地图获取地理位置信息、如何用c++调用mediainfo获取信息、用,请问如何调用GetSystemInfo函数读取系统信息等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)