Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

You need to follow the Bing Maps SDK instructions here: https://github.com/blinkmobile/cordova-plugin-map#installation (don't bother actually installing the Cordova plugin unless you intend to use it)


Content.html
<div id="bing-map"></div>
init.js
// this UMD-wrapper lets us write code that works in both BICs!

(function (root, factory) {

  'use strict';

  if (typeof define === 'function' && define.amd) {

    require(['jquery'], factory);

  } else {

  	factory(root.$);

  }

}(this, function ($) {

  'use strict';




	// if we're in the Windows app, try to load in the device's copy of Bing Maps SDK

	if (window.MSApp) {

		MSApp.execUnsafeLocalFunction(function () {

      // can't use jQuery for this, because we end up with non-executable junk ("text/inert")

			var script = document.createElement('script');

			script.setAttribute('type', 'text/javascript');

			script.setAttribute('src', 'ms-appx:///Bing.Maps.JavaScript//js/veapicore.js');

			document.head.appendChild(script);

    });

	}




	// we'll just check the page after each navigation

	$(document).on('pageshow', function () {




    var mapDiv = document.getElementById('bing-map');




		if (!mapDiv) {

			return; // can't find our DIV, so exit early

		}




    if (!window.Microsoft || !window.Microsoft.Maps || !window.Microsoft.Maps.loadModule) {

      return; // can't find the Microsoft APIs, so exit early

    }




    Microsoft.Maps.loadModule('Microsoft.Maps.Map', {

      callback: function () {

        return new Microsoft.Maps.Map(mapDiv, {

          credentials: 'HntzIgiBMFfcPuWIOZSs~gOkdkyrge56xgqvxWfzSCg~AjvxMVNOzPkKf3RubOeTV5RKa1ukcr9PyNRsaflQuSge8hLxGrXTXVyvhb7DJXaa',

          width: 400,

          height: 400

        });

      },

      culture: 'en-us',

      homeRegion: 'AU'

    });

  });




}));




  • No labels