WxWidgets:Example:GoogleMaps
wxWidgets Google Maps example.
Source files
main.cpp:
#include <wx/wx.h>
#include <wx/webview.h>
#define TITLE "wxGoogleMap"
#define URL "map.html" // "http://naver.com"
class MainFrame : public wxFrame
{
public:
MainFrame() : wxFrame(NULL, wxID_ANY, wxT(TITLE))
{
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(wxWebView::New(this, wxID_ANY, wxT(URL)), wxSizerFlags().Expand().Proportion(1));
SetSizer(sizer);
Show();
}
};
class MapApp : public wxApp
{
private:
MainFrame * _frame;
public:
virtual bool OnInit() override
{
_frame = new MainFrame();
return true;
}
};
// IMPLEMENT_CLASS(Application, wxApp)
IMPLEMENT_APP(MapApp);
map.html:
<!DOCTYPE html>
<html style="height: 100%;">
<head>
<meta charset=utf-8" />
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var map;
function initialize() {
var opts = {
zoom: 13,
center: new google.maps.LatLng(35.658704,139.745408),
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), opts);
}
</script>
</head>
<body style="height: 100%; margin: 0;" onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
cmake_minimum_required (VERSION 2.8)
set (PROJECT_NAME wxStartup)
project (${PROJECT_NAME})
# Setup the THIRD_PREFIX variable.
string (REPLACE "\\" "/" __tparty_home_path "$ENV{TPARTY_HOME}/local")
if (IS_DIRECTORY "${__tparty_home_path}")
list (INSERT CMAKE_PROGRAM_PATH 0 "${__tparty_home_path}/bin")
list (INSERT CMAKE_INCLUDE_PATH 0 "${__tparty_home_path}/include")
list (INSERT CMAKE_LIBRARY_PATH 0 "${__tparty_home_path}/lib")
set (wxWidgets_ROOT_DIR "${__tparty_home_path}")
else ()
message (STATUS "Not found tparty local directory: ${__tparty_home_path}")
endif ()
find_package (wxWidgets REQUIRED base core webview)
include_directories (${wxWidgets_INCLUDE_DIRS})
include_directories (${CMAKE_SOURCE_DIR})
foreach (__define_cursor ${wxWidgets_DEFINITIONS})
add_definitions (-D${__define_cursor})
endforeach ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${wxWidgets_CXX_FLAGS}")
set (SOURCE_FILES main.cpp)
add_executable (${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries (${PROJECT_NAME} PRIVATE ${wxWidgets_LIBRARIES})