// Copyright (c) The NodeRT Contributors
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the ""License""); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing permissions
// and limitations under the License.

// TODO: Verify that this is is still needed..
#define NTDDI_VERSION 0x06010000

#include <v8.h>
#include "nan.h"
#include <string>
#include <ppltasks.h>
#include "CollectionsConverter.h"
#include "CollectionsWrap.h"
#include "node-async.h"
#include "NodeRtUtils.h"
#include "OpaqueWrapper.h"
#include "WrapperBase.h"

#using <Windows.WinMD>

// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search
// Some of the node header files brings windows definitions with the same names as some of the WinRT methods
#undef DocumentProperties
#undef GetObject
#undef CreateEvent
#undef FindText
#undef SendMessage

const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__";

using v8::Array;
using v8::String;
using v8::Value;
using v8::Boolean;
using v8::Integer;
using v8::FunctionTemplate;
using v8::Object;
using v8::Local;
using v8::Function;
using v8::Date;
using v8::Number;
using v8::PropertyAttribute;
using v8::Primitive;
using Nan::HandleScope;
using Nan::Persistent;
using Nan::Undefined;
using Nan::True;
using Nan::False;
using Nan::Null;
using Nan::MaybeLocal;
using Nan::EscapableHandleScope;
using Nan::HandleScope;
using Nan::TryCatch;
using namespace concurrency;

namespace NodeRT { namespace Windows { namespace Services { namespace Maps { 
  v8::Local<v8::Value> WrapMapAddress(::Windows::Services::Maps::MapAddress^ wintRtInstance);
  ::Windows::Services::Maps::MapAddress^ UnwrapMapAddress(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapLocation(::Windows::Services::Maps::MapLocation^ wintRtInstance);
  ::Windows::Services::Maps::MapLocation^ UnwrapMapLocation(Local<Value> value);
  
  v8::Local<v8::Value> WrapManeuverWarning(::Windows::Services::Maps::ManeuverWarning^ wintRtInstance);
  ::Windows::Services::Maps::ManeuverWarning^ UnwrapManeuverWarning(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRouteManeuver(::Windows::Services::Maps::MapRouteManeuver^ wintRtInstance);
  ::Windows::Services::Maps::MapRouteManeuver^ UnwrapMapRouteManeuver(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRouteLeg(::Windows::Services::Maps::MapRouteLeg^ wintRtInstance);
  ::Windows::Services::Maps::MapRouteLeg^ UnwrapMapRouteLeg(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRoute(::Windows::Services::Maps::MapRoute^ wintRtInstance);
  ::Windows::Services::Maps::MapRoute^ UnwrapMapRoute(Local<Value> value);
  
  v8::Local<v8::Value> WrapEnhancedWaypoint(::Windows::Services::Maps::EnhancedWaypoint^ wintRtInstance);
  ::Windows::Services::Maps::EnhancedWaypoint^ UnwrapEnhancedWaypoint(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapLocationFinderResult(::Windows::Services::Maps::MapLocationFinderResult^ wintRtInstance);
  ::Windows::Services::Maps::MapLocationFinderResult^ UnwrapMapLocationFinderResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRouteFinderResult(::Windows::Services::Maps::MapRouteFinderResult^ wintRtInstance);
  ::Windows::Services::Maps::MapRouteFinderResult^ UnwrapMapRouteFinderResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRouteDrivingOptions(::Windows::Services::Maps::MapRouteDrivingOptions^ wintRtInstance);
  ::Windows::Services::Maps::MapRouteDrivingOptions^ UnwrapMapRouteDrivingOptions(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapLocationFinder(::Windows::Services::Maps::MapLocationFinder^ wintRtInstance);
  ::Windows::Services::Maps::MapLocationFinder^ UnwrapMapLocationFinder(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapRouteFinder(::Windows::Services::Maps::MapRouteFinder^ wintRtInstance);
  ::Windows::Services::Maps::MapRouteFinder^ UnwrapMapRouteFinder(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapService(::Windows::Services::Maps::MapService^ wintRtInstance);
  ::Windows::Services::Maps::MapService^ UnwrapMapService(Local<Value> value);
  
  v8::Local<v8::Value> WrapMapManager(::Windows::Services::Maps::MapManager^ wintRtInstance);
  ::Windows::Services::Maps::MapManager^ UnwrapMapManager(Local<Value> value);
  



  static void InitMapRouteOptimizationEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapRouteOptimization").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("time").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteOptimization::Time)));
    Nan::Set(enumObject, Nan::New<String>("distance").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteOptimization::Distance)));
    Nan::Set(enumObject, Nan::New<String>("timeWithTraffic").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteOptimization::TimeWithTraffic)));
  }

  static void InitMapRouteRestrictionsEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapRouteRestrictions").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::None)));
    Nan::Set(enumObject, Nan::New<String>("highways").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::Highways)));
    Nan::Set(enumObject, Nan::New<String>("tollRoads").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::TollRoads)));
    Nan::Set(enumObject, Nan::New<String>("ferries").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::Ferries)));
    Nan::Set(enumObject, Nan::New<String>("tunnels").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::Tunnels)));
    Nan::Set(enumObject, Nan::New<String>("dirtRoads").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::DirtRoads)));
    Nan::Set(enumObject, Nan::New<String>("motorail").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteRestrictions::Motorail)));
  }

  static void InitMapRouteManeuverKindEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapRouteManeuverKind").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::None)));
    Nan::Set(enumObject, Nan::New<String>("start").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::Start)));
    Nan::Set(enumObject, Nan::New<String>("stopover").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::Stopover)));
    Nan::Set(enumObject, Nan::New<String>("stopoverResume").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::StopoverResume)));
    Nan::Set(enumObject, Nan::New<String>("end").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::End)));
    Nan::Set(enumObject, Nan::New<String>("goStraight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::GoStraight)));
    Nan::Set(enumObject, Nan::New<String>("uTurnLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::UTurnLeft)));
    Nan::Set(enumObject, Nan::New<String>("uTurnRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::UTurnRight)));
    Nan::Set(enumObject, Nan::New<String>("turnKeepLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnKeepLeft)));
    Nan::Set(enumObject, Nan::New<String>("turnKeepRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnKeepRight)));
    Nan::Set(enumObject, Nan::New<String>("turnLightLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnLightLeft)));
    Nan::Set(enumObject, Nan::New<String>("turnLightRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnLightRight)));
    Nan::Set(enumObject, Nan::New<String>("turnLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnLeft)));
    Nan::Set(enumObject, Nan::New<String>("turnRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnRight)));
    Nan::Set(enumObject, Nan::New<String>("turnHardLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnHardLeft)));
    Nan::Set(enumObject, Nan::New<String>("turnHardRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TurnHardRight)));
    Nan::Set(enumObject, Nan::New<String>("freewayEnterLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayEnterLeft)));
    Nan::Set(enumObject, Nan::New<String>("freewayEnterRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayEnterRight)));
    Nan::Set(enumObject, Nan::New<String>("freewayLeaveLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayLeaveLeft)));
    Nan::Set(enumObject, Nan::New<String>("freewayLeaveRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayLeaveRight)));
    Nan::Set(enumObject, Nan::New<String>("freewayContinueLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayContinueLeft)));
    Nan::Set(enumObject, Nan::New<String>("freewayContinueRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::FreewayContinueRight)));
    Nan::Set(enumObject, Nan::New<String>("trafficCircleLeft").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TrafficCircleLeft)));
    Nan::Set(enumObject, Nan::New<String>("trafficCircleRight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TrafficCircleRight)));
    Nan::Set(enumObject, Nan::New<String>("takeFerry").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteManeuverKind::TakeFerry)));
  }

  static void InitMapManeuverNoticesEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapManeuverNotices").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapManeuverNotices::None)));
    Nan::Set(enumObject, Nan::New<String>("toll").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapManeuverNotices::Toll)));
    Nan::Set(enumObject, Nan::New<String>("unpaved").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapManeuverNotices::Unpaved)));
  }

  static void InitMapLocationFinderStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapLocationFinderStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("unknownError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::UnknownError)));
    Nan::Set(enumObject, Nan::New<String>("invalidCredentials").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::InvalidCredentials)));
    Nan::Set(enumObject, Nan::New<String>("badLocation").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::BadLocation)));
    Nan::Set(enumObject, Nan::New<String>("indexFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::IndexFailure)));
    Nan::Set(enumObject, Nan::New<String>("networkFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::NetworkFailure)));
    Nan::Set(enumObject, Nan::New<String>("notSupported").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationFinderStatus::NotSupported)));
  }

  static void InitMapRouteFinderStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapRouteFinderStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("unknownError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::UnknownError)));
    Nan::Set(enumObject, Nan::New<String>("invalidCredentials").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::InvalidCredentials)));
    Nan::Set(enumObject, Nan::New<String>("noRouteFound").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::NoRouteFound)));
    Nan::Set(enumObject, Nan::New<String>("noRouteFoundWithGivenOptions").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::NoRouteFoundWithGivenOptions)));
    Nan::Set(enumObject, Nan::New<String>("startPointNotFound").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::StartPointNotFound)));
    Nan::Set(enumObject, Nan::New<String>("endPointNotFound").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::EndPointNotFound)));
    Nan::Set(enumObject, Nan::New<String>("noPedestrianRouteFound").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::NoPedestrianRouteFound)));
    Nan::Set(enumObject, Nan::New<String>("networkFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::NetworkFailure)));
    Nan::Set(enumObject, Nan::New<String>("notSupported").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapRouteFinderStatus::NotSupported)));
  }

  static void InitMapLocationDesiredAccuracyEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapLocationDesiredAccuracy").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("high").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationDesiredAccuracy::High)));
    Nan::Set(enumObject, Nan::New<String>("low").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapLocationDesiredAccuracy::Low)));
  }

  static void InitWaypointKindEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("WaypointKind").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("stop").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::WaypointKind::Stop)));
    Nan::Set(enumObject, Nan::New<String>("via").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::WaypointKind::Via)));
  }

  static void InitMapServiceDataUsagePreferenceEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MapServiceDataUsagePreference").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("default").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapServiceDataUsagePreference::Default)));
    Nan::Set(enumObject, Nan::New<String>("offlineMapDataOnly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::MapServiceDataUsagePreference::OfflineMapDataOnly)));
  }

  static void InitTrafficCongestionEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("TrafficCongestion").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::TrafficCongestion::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("light").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::TrafficCongestion::Light)));
    Nan::Set(enumObject, Nan::New<String>("mild").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::TrafficCongestion::Mild)));
    Nan::Set(enumObject, Nan::New<String>("medium").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::TrafficCongestion::Medium)));
    Nan::Set(enumObject, Nan::New<String>("heavy").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::TrafficCongestion::Heavy)));
  }

  static void InitManeuverWarningKindEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ManeuverWarningKind").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::None)));
    Nan::Set(enumObject, Nan::New<String>("accident").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Accident)));
    Nan::Set(enumObject, Nan::New<String>("administrativeDivisionChange").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::AdministrativeDivisionChange)));
    Nan::Set(enumObject, Nan::New<String>("alert").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Alert)));
    Nan::Set(enumObject, Nan::New<String>("blockedRoad").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::BlockedRoad)));
    Nan::Set(enumObject, Nan::New<String>("checkTimetable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::CheckTimetable)));
    Nan::Set(enumObject, Nan::New<String>("congestion").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Congestion)));
    Nan::Set(enumObject, Nan::New<String>("construction").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Construction)));
    Nan::Set(enumObject, Nan::New<String>("countryChange").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::CountryChange)));
    Nan::Set(enumObject, Nan::New<String>("disabledVehicle").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::DisabledVehicle)));
    Nan::Set(enumObject, Nan::New<String>("gateAccess").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::GateAccess)));
    Nan::Set(enumObject, Nan::New<String>("getOffTransit").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::GetOffTransit)));
    Nan::Set(enumObject, Nan::New<String>("getOnTransit").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::GetOnTransit)));
    Nan::Set(enumObject, Nan::New<String>("illegalUTurn").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::IllegalUTurn)));
    Nan::Set(enumObject, Nan::New<String>("massTransit").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::MassTransit)));
    Nan::Set(enumObject, Nan::New<String>("miscellaneous").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Miscellaneous)));
    Nan::Set(enumObject, Nan::New<String>("noIncident").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::NoIncident)));
    Nan::Set(enumObject, Nan::New<String>("other").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Other)));
    Nan::Set(enumObject, Nan::New<String>("otherNews").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::OtherNews)));
    Nan::Set(enumObject, Nan::New<String>("otherTrafficIncidents").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::OtherTrafficIncidents)));
    Nan::Set(enumObject, Nan::New<String>("plannedEvent").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::PlannedEvent)));
    Nan::Set(enumObject, Nan::New<String>("privateRoad").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::PrivateRoad)));
    Nan::Set(enumObject, Nan::New<String>("restrictedTurn").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::RestrictedTurn)));
    Nan::Set(enumObject, Nan::New<String>("roadClosures").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::RoadClosures)));
    Nan::Set(enumObject, Nan::New<String>("roadHazard").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::RoadHazard)));
    Nan::Set(enumObject, Nan::New<String>("scheduledConstruction").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::ScheduledConstruction)));
    Nan::Set(enumObject, Nan::New<String>("seasonalClosures").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::SeasonalClosures)));
    Nan::Set(enumObject, Nan::New<String>("tollbooth").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Tollbooth)));
    Nan::Set(enumObject, Nan::New<String>("tollRoad").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::TollRoad)));
    Nan::Set(enumObject, Nan::New<String>("tollZoneEnter").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::TollZoneEnter)));
    Nan::Set(enumObject, Nan::New<String>("tollZoneExit").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::TollZoneExit)));
    Nan::Set(enumObject, Nan::New<String>("trafficFlow").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::TrafficFlow)));
    Nan::Set(enumObject, Nan::New<String>("transitLineChange").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::TransitLineChange)));
    Nan::Set(enumObject, Nan::New<String>("unpavedRoad").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::UnpavedRoad)));
    Nan::Set(enumObject, Nan::New<String>("unscheduledConstruction").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::UnscheduledConstruction)));
    Nan::Set(enumObject, Nan::New<String>("weather").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningKind::Weather)));
  }

  static void InitManeuverWarningSeverityEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ManeuverWarningSeverity").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningSeverity::None)));
    Nan::Set(enumObject, Nan::New<String>("lowImpact").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningSeverity::LowImpact)));
    Nan::Set(enumObject, Nan::New<String>("minor").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningSeverity::Minor)));
    Nan::Set(enumObject, Nan::New<String>("moderate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningSeverity::Moderate)));
    Nan::Set(enumObject, Nan::New<String>("serious").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Services::Maps::ManeuverWarningSeverity::Serious)));
  }

  static bool IsGuidanceContractJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Services::Maps::GuidanceContract GuidanceContractFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Services::Maps::GuidanceContract returnValue;

    if (!value->IsObject()) {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    return returnValue;
  }

  Local<Value> GuidanceContractToJsObject(::Windows::Services::Maps::GuidanceContract value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }
  static bool IsLocalSearchContractJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Services::Maps::LocalSearchContract LocalSearchContractFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Services::Maps::LocalSearchContract returnValue;

    if (!value->IsObject()) {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    return returnValue;
  }

  Local<Value> LocalSearchContractToJsObject(::Windows::Services::Maps::LocalSearchContract value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }


  class MapAddress : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapAddress").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("buildingFloor").ToLocalChecked(), BuildingFloorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("buildingName").ToLocalChecked(), BuildingNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("buildingRoom").ToLocalChecked(), BuildingRoomGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("buildingWing").ToLocalChecked(), BuildingWingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("continent").ToLocalChecked(), ContinentGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("country").ToLocalChecked(), CountryGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("countryCode").ToLocalChecked(), CountryCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("district").ToLocalChecked(), DistrictGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("neighborhood").ToLocalChecked(), NeighborhoodGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("postCode").ToLocalChecked(), PostCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("region").ToLocalChecked(), RegionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("regionCode").ToLocalChecked(), RegionCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("street").ToLocalChecked(), StreetGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("streetNumber").ToLocalChecked(), StreetNumberGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("town").ToLocalChecked(), TownGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("formattedAddress").ToLocalChecked(), FormattedAddressGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapAddress").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapAddress(::Windows::Services::Maps::MapAddress^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapAddress^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapAddress^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapAddress *wrapperInstance = new MapAddress(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapAddress^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapAddress^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapAddress(winRtInstance));
    }





    static void BuildingFloorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->BuildingFloor;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BuildingNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->BuildingName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BuildingRoomGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->BuildingRoom;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BuildingWingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->BuildingWing;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ContinentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Continent;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CountryGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Country;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CountryCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->CountryCode;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DistrictGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->District;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NeighborhoodGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Neighborhood;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PostCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->PostCode;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RegionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Region;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RegionCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->RegionCode;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StreetGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Street;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StreetNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->StreetNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TownGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Town;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FormattedAddressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapAddress^>(info.This())) {
        return;
      }

      MapAddress *wrapper = MapAddress::Unwrap<MapAddress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->FormattedAddress;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapAddress^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapAddress(::Windows::Services::Maps::MapAddress^ wintRtInstance);
      friend ::Windows::Services::Maps::MapAddress^ UnwrapMapAddress(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapAddress::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapAddress(::Windows::Services::Maps::MapAddress^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapAddress::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapAddress^ UnwrapMapAddress(Local<Value> value) {
     return MapAddress::Unwrap<MapAddress>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapAddress(Local<Object> exports) {
    MapAddress::Init(exports);
  }

  class MapLocation : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapLocation").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("address").ToLocalChecked(), AddressGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("point").ToLocalChecked(), PointGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapLocation").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapLocation(::Windows::Services::Maps::MapLocation^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapLocation^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapLocation^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapLocation *wrapperInstance = new MapLocation(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapLocation^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapLocation^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapLocation(winRtInstance));
    }





    static void AddressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info.This())) {
        return;
      }

      MapLocation *wrapper = MapLocation::Unwrap<MapLocation>(info.This());

      try  {
        ::Windows::Services::Maps::MapAddress^ result = wrapper->_instance->Address;
        info.GetReturnValue().Set(WrapMapAddress(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info.This())) {
        return;
      }

      MapLocation *wrapper = MapLocation::Unwrap<MapLocation>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info.This())) {
        return;
      }

      MapLocation *wrapper = MapLocation::Unwrap<MapLocation>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->DisplayName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PointGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(info.This())) {
        return;
      }

      MapLocation *wrapper = MapLocation::Unwrap<MapLocation>(info.This());

      try  {
        ::Windows::Devices::Geolocation::Geopoint^ result = wrapper->_instance->Point;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "Geopoint", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapLocation^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapLocation(::Windows::Services::Maps::MapLocation^ wintRtInstance);
      friend ::Windows::Services::Maps::MapLocation^ UnwrapMapLocation(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapLocation::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapLocation(::Windows::Services::Maps::MapLocation^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapLocation::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapLocation^ UnwrapMapLocation(Local<Value> value) {
     return MapLocation::Unwrap<MapLocation>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapLocation(Local<Object> exports) {
    MapLocation::Init(exports);
  }

  class ManeuverWarning : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("ManeuverWarning").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("kind").ToLocalChecked(), KindGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("severity").ToLocalChecked(), SeverityGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ManeuverWarning").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ManeuverWarning(::Windows::Services::Maps::ManeuverWarning^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::ManeuverWarning^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::ManeuverWarning^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::ManeuverWarning^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      ManeuverWarning *wrapperInstance = new ManeuverWarning(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::ManeuverWarning^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::ManeuverWarning^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::ManeuverWarning^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapManeuverWarning(winRtInstance));
    }





    static void KindGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::ManeuverWarning^>(info.This())) {
        return;
      }

      ManeuverWarning *wrapper = ManeuverWarning::Unwrap<ManeuverWarning>(info.This());

      try  {
        ::Windows::Services::Maps::ManeuverWarningKind result = wrapper->_instance->Kind;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SeverityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::ManeuverWarning^>(info.This())) {
        return;
      }

      ManeuverWarning *wrapper = ManeuverWarning::Unwrap<ManeuverWarning>(info.This());

      try  {
        ::Windows::Services::Maps::ManeuverWarningSeverity result = wrapper->_instance->Severity;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::ManeuverWarning^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapManeuverWarning(::Windows::Services::Maps::ManeuverWarning^ wintRtInstance);
      friend ::Windows::Services::Maps::ManeuverWarning^ UnwrapManeuverWarning(Local<Value> value);
  };

  Persistent<FunctionTemplate> ManeuverWarning::s_constructorTemplate;

  v8::Local<v8::Value> WrapManeuverWarning(::Windows::Services::Maps::ManeuverWarning^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(ManeuverWarning::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::ManeuverWarning^ UnwrapManeuverWarning(Local<Value> value) {
     return ManeuverWarning::Unwrap<ManeuverWarning>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitManeuverWarning(Local<Object> exports) {
    ManeuverWarning::Init(exports);
  }

  class MapRouteManeuver : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRouteManeuver").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exitNumber").ToLocalChecked(), ExitNumberGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("instructionText").ToLocalChecked(), InstructionTextGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("kind").ToLocalChecked(), KindGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lengthInMeters").ToLocalChecked(), LengthInMetersGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maneuverNotices").ToLocalChecked(), ManeuverNoticesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("startingPoint").ToLocalChecked(), StartingPointGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("endHeading").ToLocalChecked(), EndHeadingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("startHeading").ToLocalChecked(), StartHeadingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("streetName").ToLocalChecked(), StreetNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("warnings").ToLocalChecked(), WarningsGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapRouteManeuver").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRouteManeuver(::Windows::Services::Maps::MapRouteManeuver^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRouteManeuver^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRouteManeuver^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRouteManeuver *wrapperInstance = new MapRouteManeuver(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRouteManeuver^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRouteManeuver^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRouteManeuver(winRtInstance));
    }





    static void ExitNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ExitNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void InstructionTextGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->InstructionText;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void KindGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        ::Windows::Services::Maps::MapRouteManeuverKind result = wrapper->_instance->Kind;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LengthInMetersGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        double result = wrapper->_instance->LengthInMeters;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ManeuverNoticesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        ::Windows::Services::Maps::MapManeuverNotices result = wrapper->_instance->ManeuverNotices;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StartingPointGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        ::Windows::Devices::Geolocation::Geopoint^ result = wrapper->_instance->StartingPoint;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "Geopoint", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EndHeadingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        double result = wrapper->_instance->EndHeading;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StartHeadingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        double result = wrapper->_instance->StartHeading;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StreetNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->StreetName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WarningsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(info.This())) {
        return;
      }

      MapRouteManeuver *wrapper = MapRouteManeuver::Unwrap<MapRouteManeuver>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Services::Maps::ManeuverWarning^>^ result = wrapper->_instance->Warnings;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Services::Maps::ManeuverWarning^>::CreateVectorViewWrapper(result, 
            [](::Windows::Services::Maps::ManeuverWarning^ val) -> Local<Value> {
              return WrapManeuverWarning(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::ManeuverWarning^>(value);
            },
            [](Local<Value> value) -> ::Windows::Services::Maps::ManeuverWarning^ {
              return UnwrapManeuverWarning(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapRouteManeuver^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRouteManeuver(::Windows::Services::Maps::MapRouteManeuver^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRouteManeuver^ UnwrapMapRouteManeuver(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRouteManeuver::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRouteManeuver(::Windows::Services::Maps::MapRouteManeuver^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRouteManeuver::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRouteManeuver^ UnwrapMapRouteManeuver(Local<Value> value) {
     return MapRouteManeuver::Unwrap<MapRouteManeuver>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRouteManeuver(Local<Object> exports) {
    MapRouteManeuver::Init(exports);
  }

  class MapRouteLeg : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRouteLeg").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("boundingBox").ToLocalChecked(), BoundingBoxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("estimatedDuration").ToLocalChecked(), EstimatedDurationGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lengthInMeters").ToLocalChecked(), LengthInMetersGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maneuvers").ToLocalChecked(), ManeuversGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("path").ToLocalChecked(), PathGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("durationWithoutTraffic").ToLocalChecked(), DurationWithoutTrafficGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("trafficCongestion").ToLocalChecked(), TrafficCongestionGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapRouteLeg").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRouteLeg(::Windows::Services::Maps::MapRouteLeg^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRouteLeg^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRouteLeg^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRouteLeg *wrapperInstance = new MapRouteLeg(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRouteLeg^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRouteLeg^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRouteLeg(winRtInstance));
    }





    static void BoundingBoxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Devices::Geolocation::GeoboundingBox^ result = wrapper->_instance->BoundingBox;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "GeoboundingBox", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EstimatedDurationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->EstimatedDuration;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LengthInMetersGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        double result = wrapper->_instance->LengthInMeters;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ManeuversGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Services::Maps::MapRouteManeuver^>^ result = wrapper->_instance->Maneuvers;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Services::Maps::MapRouteManeuver^>::CreateVectorViewWrapper(result, 
            [](::Windows::Services::Maps::MapRouteManeuver^ val) -> Local<Value> {
              return WrapMapRouteManeuver(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteManeuver^>(value);
            },
            [](Local<Value> value) -> ::Windows::Services::Maps::MapRouteManeuver^ {
              return UnwrapMapRouteManeuver(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PathGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Devices::Geolocation::Geopath^ result = wrapper->_instance->Path;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "Geopath", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DurationWithoutTrafficGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->DurationWithoutTraffic;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TrafficCongestionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(info.This())) {
        return;
      }

      MapRouteLeg *wrapper = MapRouteLeg::Unwrap<MapRouteLeg>(info.This());

      try  {
        ::Windows::Services::Maps::TrafficCongestion result = wrapper->_instance->TrafficCongestion;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapRouteLeg^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRouteLeg(::Windows::Services::Maps::MapRouteLeg^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRouteLeg^ UnwrapMapRouteLeg(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRouteLeg::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRouteLeg(::Windows::Services::Maps::MapRouteLeg^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRouteLeg::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRouteLeg^ UnwrapMapRouteLeg(Local<Value> value) {
     return MapRouteLeg::Unwrap<MapRouteLeg>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRouteLeg(Local<Object> exports) {
    MapRouteLeg::Init(exports);
  }

  class MapRoute : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRoute").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("boundingBox").ToLocalChecked(), BoundingBoxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("estimatedDuration").ToLocalChecked(), EstimatedDurationGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isTrafficBased").ToLocalChecked(), IsTrafficBasedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("legs").ToLocalChecked(), LegsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lengthInMeters").ToLocalChecked(), LengthInMetersGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("path").ToLocalChecked(), PathGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hasBlockedRoads").ToLocalChecked(), HasBlockedRoadsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("violatedRestrictions").ToLocalChecked(), ViolatedRestrictionsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("durationWithoutTraffic").ToLocalChecked(), DurationWithoutTrafficGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("trafficCongestion").ToLocalChecked(), TrafficCongestionGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapRoute").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRoute(::Windows::Services::Maps::MapRoute^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRoute^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRoute^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRoute *wrapperInstance = new MapRoute(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRoute^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRoute^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRoute(winRtInstance));
    }





    static void BoundingBoxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Devices::Geolocation::GeoboundingBox^ result = wrapper->_instance->BoundingBox;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "GeoboundingBox", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EstimatedDurationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->EstimatedDuration;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsTrafficBasedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        bool result = wrapper->_instance->IsTrafficBased;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LegsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Services::Maps::MapRouteLeg^>^ result = wrapper->_instance->Legs;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Services::Maps::MapRouteLeg^>::CreateVectorViewWrapper(result, 
            [](::Windows::Services::Maps::MapRouteLeg^ val) -> Local<Value> {
              return WrapMapRouteLeg(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteLeg^>(value);
            },
            [](Local<Value> value) -> ::Windows::Services::Maps::MapRouteLeg^ {
              return UnwrapMapRouteLeg(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LengthInMetersGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        double result = wrapper->_instance->LengthInMeters;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PathGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Devices::Geolocation::Geopath^ result = wrapper->_instance->Path;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "Geopath", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void HasBlockedRoadsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        bool result = wrapper->_instance->HasBlockedRoads;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ViolatedRestrictionsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Services::Maps::MapRouteRestrictions result = wrapper->_instance->ViolatedRestrictions;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DurationWithoutTrafficGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->DurationWithoutTraffic;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TrafficCongestionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(info.This())) {
        return;
      }

      MapRoute *wrapper = MapRoute::Unwrap<MapRoute>(info.This());

      try  {
        ::Windows::Services::Maps::TrafficCongestion result = wrapper->_instance->TrafficCongestion;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapRoute^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRoute(::Windows::Services::Maps::MapRoute^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRoute^ UnwrapMapRoute(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRoute::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRoute(::Windows::Services::Maps::MapRoute^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRoute::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRoute^ UnwrapMapRoute(Local<Value> value) {
     return MapRoute::Unwrap<MapRoute>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRoute(Local<Object> exports) {
    MapRoute::Init(exports);
  }

  class EnhancedWaypoint : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("EnhancedWaypoint").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("kind").ToLocalChecked(), KindGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("point").ToLocalChecked(), PointGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("EnhancedWaypoint").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      EnhancedWaypoint(::Windows::Services::Maps::EnhancedWaypoint^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::EnhancedWaypoint^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::EnhancedWaypoint^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
        && info[1]->IsInt32())
      {
        try {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Services::Maps::WaypointKind arg1 = static_cast<::Windows::Services::Maps::WaypointKind>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          
          winRtInstance = ref new ::Windows::Services::Maps::EnhancedWaypoint(arg0,arg1);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      EnhancedWaypoint *wrapperInstance = new EnhancedWaypoint(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::EnhancedWaypoint^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::EnhancedWaypoint^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapEnhancedWaypoint(winRtInstance));
    }





    static void KindGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(info.This())) {
        return;
      }

      EnhancedWaypoint *wrapper = EnhancedWaypoint::Unwrap<EnhancedWaypoint>(info.This());

      try  {
        ::Windows::Services::Maps::WaypointKind result = wrapper->_instance->Kind;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PointGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(info.This())) {
        return;
      }

      EnhancedWaypoint *wrapper = EnhancedWaypoint::Unwrap<EnhancedWaypoint>(info.This());

      try  {
        ::Windows::Devices::Geolocation::Geopoint^ result = wrapper->_instance->Point;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Geolocation", "Geopoint", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::EnhancedWaypoint^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapEnhancedWaypoint(::Windows::Services::Maps::EnhancedWaypoint^ wintRtInstance);
      friend ::Windows::Services::Maps::EnhancedWaypoint^ UnwrapEnhancedWaypoint(Local<Value> value);
  };

  Persistent<FunctionTemplate> EnhancedWaypoint::s_constructorTemplate;

  v8::Local<v8::Value> WrapEnhancedWaypoint(::Windows::Services::Maps::EnhancedWaypoint^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(EnhancedWaypoint::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::EnhancedWaypoint^ UnwrapEnhancedWaypoint(Local<Value> value) {
     return EnhancedWaypoint::Unwrap<EnhancedWaypoint>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitEnhancedWaypoint(Local<Object> exports) {
    EnhancedWaypoint::Init(exports);
  }

  class MapLocationFinderResult : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapLocationFinderResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("locations").ToLocalChecked(), LocationsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapLocationFinderResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapLocationFinderResult(::Windows::Services::Maps::MapLocationFinderResult^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapLocationFinderResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinderResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapLocationFinderResult^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapLocationFinderResult *wrapperInstance = new MapLocationFinderResult(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinderResult^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapLocationFinderResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapLocationFinderResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapLocationFinderResult(winRtInstance));
    }





    static void LocationsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinderResult^>(info.This())) {
        return;
      }

      MapLocationFinderResult *wrapper = MapLocationFinderResult::Unwrap<MapLocationFinderResult>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Services::Maps::MapLocation^>^ result = wrapper->_instance->Locations;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Services::Maps::MapLocation^>::CreateVectorViewWrapper(result, 
            [](::Windows::Services::Maps::MapLocation^ val) -> Local<Value> {
              return WrapMapLocation(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocation^>(value);
            },
            [](Local<Value> value) -> ::Windows::Services::Maps::MapLocation^ {
              return UnwrapMapLocation(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinderResult^>(info.This())) {
        return;
      }

      MapLocationFinderResult *wrapper = MapLocationFinderResult::Unwrap<MapLocationFinderResult>(info.This());

      try  {
        ::Windows::Services::Maps::MapLocationFinderStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapLocationFinderResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapLocationFinderResult(::Windows::Services::Maps::MapLocationFinderResult^ wintRtInstance);
      friend ::Windows::Services::Maps::MapLocationFinderResult^ UnwrapMapLocationFinderResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapLocationFinderResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapLocationFinderResult(::Windows::Services::Maps::MapLocationFinderResult^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapLocationFinderResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapLocationFinderResult^ UnwrapMapLocationFinderResult(Local<Value> value) {
     return MapLocationFinderResult::Unwrap<MapLocationFinderResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapLocationFinderResult(Local<Object> exports) {
    MapLocationFinderResult::Init(exports);
  }

  class MapRouteFinderResult : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRouteFinderResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("route").ToLocalChecked(), RouteGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("alternateRoutes").ToLocalChecked(), AlternateRoutesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapRouteFinderResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRouteFinderResult(::Windows::Services::Maps::MapRouteFinderResult^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRouteFinderResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinderResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRouteFinderResult^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRouteFinderResult *wrapperInstance = new MapRouteFinderResult(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinderResult^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRouteFinderResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRouteFinderResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRouteFinderResult(winRtInstance));
    }





    static void RouteGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinderResult^>(info.This())) {
        return;
      }

      MapRouteFinderResult *wrapper = MapRouteFinderResult::Unwrap<MapRouteFinderResult>(info.This());

      try  {
        ::Windows::Services::Maps::MapRoute^ result = wrapper->_instance->Route;
        info.GetReturnValue().Set(WrapMapRoute(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinderResult^>(info.This())) {
        return;
      }

      MapRouteFinderResult *wrapper = MapRouteFinderResult::Unwrap<MapRouteFinderResult>(info.This());

      try  {
        ::Windows::Services::Maps::MapRouteFinderStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AlternateRoutesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinderResult^>(info.This())) {
        return;
      }

      MapRouteFinderResult *wrapper = MapRouteFinderResult::Unwrap<MapRouteFinderResult>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Services::Maps::MapRoute^>^ result = wrapper->_instance->AlternateRoutes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Services::Maps::MapRoute^>::CreateVectorViewWrapper(result, 
            [](::Windows::Services::Maps::MapRoute^ val) -> Local<Value> {
              return WrapMapRoute(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRoute^>(value);
            },
            [](Local<Value> value) -> ::Windows::Services::Maps::MapRoute^ {
              return UnwrapMapRoute(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Services::Maps::MapRouteFinderResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRouteFinderResult(::Windows::Services::Maps::MapRouteFinderResult^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRouteFinderResult^ UnwrapMapRouteFinderResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRouteFinderResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRouteFinderResult(::Windows::Services::Maps::MapRouteFinderResult^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRouteFinderResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRouteFinderResult^ UnwrapMapRouteFinderResult(Local<Value> value) {
     return MapRouteFinderResult::Unwrap<MapRouteFinderResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRouteFinderResult(Local<Object> exports) {
    MapRouteFinderResult::Init(exports);
  }

  class MapRouteDrivingOptions : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRouteDrivingOptions").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("routeRestrictions").ToLocalChecked(), RouteRestrictionsGetter, RouteRestrictionsSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("routeOptimization").ToLocalChecked(), RouteOptimizationGetter, RouteOptimizationSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maxAlternateRouteCount").ToLocalChecked(), MaxAlternateRouteCountGetter, MaxAlternateRouteCountSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("initialHeading").ToLocalChecked(), InitialHeadingGetter, InitialHeadingSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MapRouteDrivingOptions").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRouteDrivingOptions(::Windows::Services::Maps::MapRouteDrivingOptions^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRouteDrivingOptions^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRouteDrivingOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Services::Maps::MapRouteDrivingOptions();
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRouteDrivingOptions *wrapperInstance = new MapRouteDrivingOptions(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRouteDrivingOptions^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRouteDrivingOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRouteDrivingOptions(winRtInstance));
    }





    static void RouteRestrictionsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try  {
        ::Windows::Services::Maps::MapRouteRestrictions result = wrapper->_instance->RouteRestrictions;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RouteRestrictionsSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try {

        ::Windows::Services::Maps::MapRouteRestrictions winRtValue = static_cast<::Windows::Services::Maps::MapRouteRestrictions>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->RouteRestrictions = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void RouteOptimizationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try  {
        ::Windows::Services::Maps::MapRouteOptimization result = wrapper->_instance->RouteOptimization;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RouteOptimizationSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try {

        ::Windows::Services::Maps::MapRouteOptimization winRtValue = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->RouteOptimization = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void MaxAlternateRouteCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try  {
        unsigned int result = wrapper->_instance->MaxAlternateRouteCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxAlternateRouteCountSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try {

        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->MaxAlternateRouteCount = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void InitialHeadingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try  {
        ::Platform::IBox<double>^ result = wrapper->_instance->InitialHeading;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Number>(static_cast<double>(result->Value))) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void InitialHeadingSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info.This())) {
        return;
      }

      MapRouteDrivingOptions *wrapper = MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(info.This());

      try {

        ::Platform::IBox<double>^ winRtValue = ref new ::Platform::Box<double>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->InitialHeading = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Services::Maps::MapRouteDrivingOptions^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRouteDrivingOptions(::Windows::Services::Maps::MapRouteDrivingOptions^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRouteDrivingOptions^ UnwrapMapRouteDrivingOptions(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRouteDrivingOptions::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRouteDrivingOptions(::Windows::Services::Maps::MapRouteDrivingOptions^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRouteDrivingOptions::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRouteDrivingOptions^ UnwrapMapRouteDrivingOptions(Local<Value> value) {
     return MapRouteDrivingOptions::Unwrap<MapRouteDrivingOptions>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRouteDrivingOptions(Local<Object> exports) {
    MapRouteDrivingOptions::Init(exports);
  }

  class MapLocationFinder : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapLocationFinder").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        func = Nan::GetFunction(Nan::New<FunctionTemplate>(FindLocationsAtAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("findLocationsAtAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(FindLocationsAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("findLocationsAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("MapLocationFinder").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapLocationFinder(::Windows::Services::Maps::MapLocationFinder^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapLocationFinder^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinder^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapLocationFinder^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapLocationFinder *wrapperInstance = new MapLocationFinder(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapLocationFinder^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapLocationFinder^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapLocationFinder^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapLocationFinder(winRtInstance));
    }




    static void FindLocationsAtAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapLocationFinderResult^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && info[1]->IsInt32())
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Services::Maps::MapLocationDesiredAccuracy arg1 = static_cast<::Windows::Services::Maps::MapLocationDesiredAccuracy>(Nan::To<int32_t>(info[1]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapLocationFinder::FindLocationsAtAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0]))
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Services::Maps::MapLocationFinder::FindLocationsAtAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapLocationFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapLocationFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void FindLocationsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapLocationFinderResult^>^ op;


      if (info.Length() == 3
          && info[0]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Services::Maps::MapLocationFinder::FindLocationsAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 4
          && info[0]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1])
          && info[2]->IsUint32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
          unsigned int arg2 = static_cast<unsigned int>(Nan::To<uint32_t>(info[2]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapLocationFinder::FindLocationsAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapLocationFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapLocationFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    private:
      ::Windows::Services::Maps::MapLocationFinder^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapLocationFinder(::Windows::Services::Maps::MapLocationFinder^ wintRtInstance);
      friend ::Windows::Services::Maps::MapLocationFinder^ UnwrapMapLocationFinder(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapLocationFinder::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapLocationFinder(::Windows::Services::Maps::MapLocationFinder^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapLocationFinder::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapLocationFinder^ UnwrapMapLocationFinder(Local<Value> value) {
     return MapLocationFinder::Unwrap<MapLocationFinder>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapLocationFinder(Local<Object> exports) {
    MapLocationFinder::Init(exports);
  }

  class MapRouteFinder : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapRouteFinder").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetDrivingRouteFromEnhancedWaypointsAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getDrivingRouteFromEnhancedWaypointsAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetDrivingRouteAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getDrivingRouteAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetDrivingRouteFromWaypointsAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getDrivingRouteFromWaypointsAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetWalkingRouteAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getWalkingRouteAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetWalkingRouteFromWaypointsAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getWalkingRouteFromWaypointsAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("MapRouteFinder").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapRouteFinder(::Windows::Services::Maps::MapRouteFinder^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapRouteFinder^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinder^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapRouteFinder^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapRouteFinder *wrapperInstance = new MapRouteFinder(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteFinder^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapRouteFinder^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapRouteFinder^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapRouteFinder(winRtInstance));
    }




    static void GetDrivingRouteFromEnhancedWaypointsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapRouteFinderResult^>^ op;


      if (info.Length() == 2
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^>(info[0]) || info[0]->IsArray()))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Services::Maps::EnhancedWaypoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Services::Maps::EnhancedWaypoint^ {
                   return UnwrapEnhancedWaypoint(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromEnhancedWaypointsAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^>(info[0]) || info[0]->IsArray())
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info[1]))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Services::Maps::EnhancedWaypoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::EnhancedWaypoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Services::Maps::EnhancedWaypoint^ {
                   return UnwrapEnhancedWaypoint(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Services::Maps::EnhancedWaypoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Windows::Services::Maps::MapRouteDrivingOptions^ arg1 = UnwrapMapRouteDrivingOptions(info[1]);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromEnhancedWaypointsAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapRouteFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapRouteFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetDrivingRouteAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapRouteFinderResult^>^ op;


      if (info.Length() == 4
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapRouteDrivingOptions^>(info[2]))
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
          ::Windows::Services::Maps::MapRouteDrivingOptions^ arg2 = UnwrapMapRouteDrivingOptions(info[2]);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1]))
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 4
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1])
          && info[2]->IsInt32())
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
          ::Windows::Services::Maps::MapRouteOptimization arg2 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[2]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 5
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1])
          && info[2]->IsInt32()
          && info[3]->IsInt32())
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
          ::Windows::Services::Maps::MapRouteOptimization arg2 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          ::Windows::Services::Maps::MapRouteRestrictions arg3 = static_cast<::Windows::Services::Maps::MapRouteRestrictions>(Nan::To<int32_t>(info[3]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteAsync(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 6
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1])
          && info[2]->IsInt32()
          && info[3]->IsInt32()
          && info[4]->IsNumber())
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
          ::Windows::Services::Maps::MapRouteOptimization arg2 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          ::Windows::Services::Maps::MapRouteRestrictions arg3 = static_cast<::Windows::Services::Maps::MapRouteRestrictions>(Nan::To<int32_t>(info[3]).FromMaybe(0));
          double arg4 = Nan::To<double>(info[4]).FromMaybe(0.0);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteAsync(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapRouteFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapRouteFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetDrivingRouteFromWaypointsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapRouteFinderResult^>^ op;


      if (info.Length() == 2
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(info[0]) || info[0]->IsArray()))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Geolocation::Geopoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Devices::Geolocation::Geopoint^ {
                   return dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromWaypointsAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsInt32())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Geolocation::Geopoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Devices::Geolocation::Geopoint^ {
                   return dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Windows::Services::Maps::MapRouteOptimization arg1 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[1]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromWaypointsAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 4
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsInt32()
          && info[2]->IsInt32())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Geolocation::Geopoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Devices::Geolocation::Geopoint^ {
                   return dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Windows::Services::Maps::MapRouteOptimization arg1 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          ::Windows::Services::Maps::MapRouteRestrictions arg2 = static_cast<::Windows::Services::Maps::MapRouteRestrictions>(Nan::To<int32_t>(info[2]).FromMaybe(0));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromWaypointsAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 5
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsInt32()
          && info[2]->IsInt32()
          && info[3]->IsNumber())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Geolocation::Geopoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Devices::Geolocation::Geopoint^ {
                   return dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Windows::Services::Maps::MapRouteOptimization arg1 = static_cast<::Windows::Services::Maps::MapRouteOptimization>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          ::Windows::Services::Maps::MapRouteRestrictions arg2 = static_cast<::Windows::Services::Maps::MapRouteRestrictions>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          double arg3 = Nan::To<double>(info[3]).FromMaybe(0.0);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetDrivingRouteFromWaypointsAsync(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapRouteFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapRouteFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetWalkingRouteAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapRouteFinderResult^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(info[1]))
      {
        try
        {
          ::Windows::Devices::Geolocation::Geopoint^ arg0 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Devices::Geolocation::Geopoint^ arg1 = dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetWalkingRouteAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapRouteFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapRouteFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetWalkingRouteFromWaypointsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Services::Maps::MapRouteFinderResult^>^ op;


      if (info.Length() == 2
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(info[0]) || info[0]->IsArray()))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Geolocation::Geopoint^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Geolocation::Geopoint^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Devices::Geolocation::Geopoint^ {
                   return dynamic_cast<::Windows::Devices::Geolocation::Geopoint^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Geolocation::Geopoint^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
            
          op = ::Windows::Services::Maps::MapRouteFinder::GetWalkingRouteFromWaypointsAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Services::Maps::MapRouteFinderResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapMapRouteFinderResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    private:
      ::Windows::Services::Maps::MapRouteFinder^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapRouteFinder(::Windows::Services::Maps::MapRouteFinder^ wintRtInstance);
      friend ::Windows::Services::Maps::MapRouteFinder^ UnwrapMapRouteFinder(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapRouteFinder::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapRouteFinder(::Windows::Services::Maps::MapRouteFinder^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapRouteFinder::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapRouteFinder^ UnwrapMapRouteFinder(Local<Value> value) {
     return MapRouteFinder::Unwrap<MapRouteFinder>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapRouteFinder(Local<Object> exports) {
    MapRouteFinder::Init(exports);
  }

  class MapService : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapService").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);






        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetAccessor(constructor, Nan::New<String>("serviceToken").ToLocalChecked(), ServiceTokenGetter, ServiceTokenSetter);
        Nan::SetAccessor(constructor, Nan::New<String>("worldViewRegionCode").ToLocalChecked(), WorldViewRegionCodeGetter);
        Nan::SetAccessor(constructor, Nan::New<String>("dataAttributions").ToLocalChecked(), DataAttributionsGetter);
        Nan::SetAccessor(constructor, Nan::New<String>("dataUsagePreference").ToLocalChecked(), DataUsagePreferenceGetter, DataUsagePreferenceSetter);


        Nan::Set(exports, Nan::New<String>("MapService").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapService(::Windows::Services::Maps::MapService^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapService^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapService^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapService^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapService *wrapperInstance = new MapService(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapService^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapService^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapService^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapService(winRtInstance));
    }







    static void ServiceTokenGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        Platform::String^ result = ::Windows::Services::Maps::MapService::ServiceToken;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void ServiceTokenSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsString()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      try {


        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        ::Windows::Services::Maps::MapService::ServiceToken = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      

    static void WorldViewRegionCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        Platform::String^ result = ::Windows::Services::Maps::MapService::WorldViewRegionCode;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void DataAttributionsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        Platform::String^ result = ::Windows::Services::Maps::MapService::DataAttributions;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void DataUsagePreferenceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        ::Windows::Services::Maps::MapServiceDataUsagePreference result = ::Windows::Services::Maps::MapService::DataUsagePreference;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void DataUsagePreferenceSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      try {


        ::Windows::Services::Maps::MapServiceDataUsagePreference winRtValue = static_cast<::Windows::Services::Maps::MapServiceDataUsagePreference>(Nan::To<int32_t>(value).FromMaybe(0));

        ::Windows::Services::Maps::MapService::DataUsagePreference = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      

    private:
      ::Windows::Services::Maps::MapService^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapService(::Windows::Services::Maps::MapService^ wintRtInstance);
      friend ::Windows::Services::Maps::MapService^ UnwrapMapService(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapService::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapService(::Windows::Services::Maps::MapService^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapService::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapService^ UnwrapMapService(Local<Value> value) {
     return MapService::Unwrap<MapService>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapService(Local<Object> exports) {
    MapService::Init(exports);
  }

  class MapManager : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("MapManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);






        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "showDownloadedMapsUI", ShowDownloadedMapsUI);
        Nan::SetMethod(constructor, "showMapsUpdateUI", ShowMapsUpdateUI);


        Nan::Set(exports, Nan::New<String>("MapManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MapManager(::Windows::Services::Maps::MapManager^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Services::Maps::MapManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Services::Maps::MapManager^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      MapManager *wrapperInstance = new MapManager(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Services::Maps::MapManager^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Services::Maps::MapManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Services::Maps::MapManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMapManager(winRtInstance));
    }





    static void ShowDownloadedMapsUI(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Services::Maps::MapManager::ShowDownloadedMapsUI();
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void ShowMapsUpdateUI(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Services::Maps::MapManager::ShowMapsUpdateUI();
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    private:
      ::Windows::Services::Maps::MapManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMapManager(::Windows::Services::Maps::MapManager^ wintRtInstance);
      friend ::Windows::Services::Maps::MapManager^ UnwrapMapManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> MapManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapMapManager(::Windows::Services::Maps::MapManager^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(MapManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Services::Maps::MapManager^ UnwrapMapManager(Local<Value> value) {
     return MapManager::Unwrap<MapManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMapManager(Local<Object> exports) {
    MapManager::Init(exports);
  }


} } } } 

NAN_MODULE_INIT(init) {
  // We ignore failures for now since it probably means that
  // the initialization already happened for STA, and that's cool

  CoInitializeEx(nullptr, COINIT_MULTITHREADED);

  /*
  if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
    Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()")));
    return;
  }
  */

      NodeRT::Windows::Services::Maps::InitMapRouteOptimizationEnum(target);
      NodeRT::Windows::Services::Maps::InitMapRouteRestrictionsEnum(target);
      NodeRT::Windows::Services::Maps::InitMapRouteManeuverKindEnum(target);
      NodeRT::Windows::Services::Maps::InitMapManeuverNoticesEnum(target);
      NodeRT::Windows::Services::Maps::InitMapLocationFinderStatusEnum(target);
      NodeRT::Windows::Services::Maps::InitMapRouteFinderStatusEnum(target);
      NodeRT::Windows::Services::Maps::InitMapLocationDesiredAccuracyEnum(target);
      NodeRT::Windows::Services::Maps::InitWaypointKindEnum(target);
      NodeRT::Windows::Services::Maps::InitMapServiceDataUsagePreferenceEnum(target);
      NodeRT::Windows::Services::Maps::InitTrafficCongestionEnum(target);
      NodeRT::Windows::Services::Maps::InitManeuverWarningKindEnum(target);
      NodeRT::Windows::Services::Maps::InitManeuverWarningSeverityEnum(target);
      NodeRT::Windows::Services::Maps::InitMapAddress(target);
      NodeRT::Windows::Services::Maps::InitMapLocation(target);
      NodeRT::Windows::Services::Maps::InitManeuverWarning(target);
      NodeRT::Windows::Services::Maps::InitMapRouteManeuver(target);
      NodeRT::Windows::Services::Maps::InitMapRouteLeg(target);
      NodeRT::Windows::Services::Maps::InitMapRoute(target);
      NodeRT::Windows::Services::Maps::InitEnhancedWaypoint(target);
      NodeRT::Windows::Services::Maps::InitMapLocationFinderResult(target);
      NodeRT::Windows::Services::Maps::InitMapRouteFinderResult(target);
      NodeRT::Windows::Services::Maps::InitMapRouteDrivingOptions(target);
      NodeRT::Windows::Services::Maps::InitMapLocationFinder(target);
      NodeRT::Windows::Services::Maps::InitMapRouteFinder(target);
      NodeRT::Windows::Services::Maps::InitMapService(target);
      NodeRT::Windows::Services::Maps::InitMapManager(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Services.Maps", target);
}



NODE_MODULE(binding, init)
