OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library google_maps; | |
6 | |
7 // This code is derived from | |
8 // https://developers.google.com/maps/documentation/javascript/tutorial#HelloWor
ld | |
9 // You can view the original JavaScript example at | |
10 // https://developers.google.com/maps/documentation/javascript/examples/map-simp
le | |
11 | |
12 import 'dart:html' show querySelector; | |
13 import 'dart:js' show context, JsObject; | |
14 | |
15 void main() { | |
16 // The top-level getter context provides a JsObject that represents the global | |
17 // object in JavaScript. | |
18 final google_maps = context['google']['maps']; | |
19 | |
20 // new JsObject() constructs a new JavaScript object and returns a proxy | |
21 // to it. | |
22 var center = new JsObject(google_maps['LatLng'], [-34.397, 150.644]); | |
23 | |
24 var mapTypeId = google_maps['MapTypeId']['ROADMAP']; | |
25 | |
26 // new JsObject.jsify() recursively converts a collection of Dart objects | |
27 // to a collection of JavaScript objects and returns a proxy to it. | |
28 var mapOptions = new JsObject.jsify({ | |
29 "center": center, | |
30 "zoom": 8, | |
31 "mapTypeId": mapTypeId | |
32 }); | |
33 | |
34 // Nodes are passed though, or transferred, not proxied. | |
35 new JsObject(google_maps['Map'], [querySelector('#map-canvas'), mapOptions]); | |
36 } | |
OLD | NEW |