Maps

enyo.Map is a wrapper around a Bing Maps control. It is found under framework/lib/systemui in the Enyo source tree. To use a Map control in an application, add the following line to the app's depend.js file:

"$enyo-lib/systemui/"

Then add the Bing Maps script to index.html, like so:

<head>
  <title>Maps</title>
  <script type="text/javascript"
      src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
  ...
</head>

In your application code, declare a Map control as follows:

{name: "map", kind: "Map", credentials: "my_bing_app_id"}

To get a handle to the actual Bing Maps control, call hasMap:

var bingMap = this.$.map.hasMap();

When a user sets the location of a pin, enyo.Map fires an onPinClick event; if a map fails to load, it triggers an onMapLoadFailure.

Published Properties

Name Default Description
latitude 37.029043436050415 The latitude of the location
longitude -101.55550763010979 The longitude of the location
zoom 4 The zoom level of the map view
showPin false If true, shows a pin at the center of the current map view.
mapType "road" The map type of the map view. Valid map types are "aerial", "auto", "birdseye", "collinsBart", "mercator", "ordnanceSurvey", and "road".
credentials "" The Bing Maps Key used to authenticate the application
options "" An object representing Bing options to customize the map that is displayed. These options can only be set at create time. For example:
{kind: "enyo.Map", options: {showDashboard: false, showCopyright: false}}

Methods

hasMap()

Returns the actual Bing Maps control.

clearAll(inExcludes)

Removes all entities from the map except the dropped pin and any pins in inExcludes.

setCenter(inLatitude, inLongitude)

Sets the location of the center of the map view. inLatitude is the latitude of the location, and inLongitude is its longitude.