Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/pkg/js/example/google-maps/marker_simple.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/js/example/google-maps/marker_simple.dart
diff --git a/third_party/pkg/js/example/google-maps/marker_simple.dart b/third_party/pkg/js/example/google-maps/marker_simple.dart
new file mode 100644
index 0000000000000000000000000000000000000000..63e291b2d36a3f45522e089ee55ff5bfa3ca1130
--- /dev/null
+++ b/third_party/pkg/js/example/google-maps/marker_simple.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// A JS Interop sample accessing the Google Maps API. The sample is based on
+// the marker-simple example here:
+// https://google-developers.appspot.com/maps/documentation/javascript/examples/marker-simple
+//
+// In this example you can see how to build a typed Dart API based on js API.
+// Doing this, you will improve developper experience (content assist, errors on
+// undefined members...).
+
+import 'dart:html';
+import 'package:js/js.dart' as js;
+
+final maps = js.context.google.maps;
+
+class LatLng implements js.Serializable<js.Proxy> {
+ final js.Proxy _proxy;
+
+ LatLng(num lat, num lng) : this._(new js.Proxy(maps.LatLng, lat, lng));
+ LatLng._(this._proxy);
+
+ js.Proxy toJs() => _proxy;
+}
+
+class MapTypeId implements js.Serializable<String> {
+ static final HYBRID = new MapTypeId._(maps.MapTypeId.HYBRID);
+ static final ROADMAP = new MapTypeId._(maps.MapTypeId.ROADMAP);
+ static final SATELLITE = new MapTypeId._(maps.MapTypeId.SATELLITE);
+ static final TERRAIN = new MapTypeId._(maps.MapTypeId.TERRAIN);
+
+ String _value;
+
+ MapTypeId._(this._value);
+
+ String toJs() => this._value;
+}
+
+class MapOptions implements js.Serializable<js.Proxy> {
+ final js.Proxy _proxy;
+
+ MapOptions() : this._(new js.Proxy(js.context.Object));
+ MapOptions._(this._proxy);
+
+ set center(LatLng center) => _proxy.center = center;
+ set mapTypeId(MapTypeId mapTypeId) => _proxy.mapTypeId = mapTypeId;
+ set zoom(num zoom) => _proxy.zoom = zoom;
+
+ js.Proxy toJs() => _proxy;
+}
+
+class GMap implements js.Serializable<js.Proxy> {
+ final js.Proxy _proxy;
+
+ GMap(Element container, MapOptions options) : this._(new js.Proxy(maps.Map, container, options));
+ GMap._(this._proxy);
+
+ set center(LatLng center) => _proxy.center = center;
+ set mapTypeId(MapTypeId mapTypeId) => _proxy.mapTypeId = mapTypeId;
+ set zoom(num zoom) => _proxy.zoom = zoom;
+
+ js.Proxy toJs() => _proxy;
+}
+
+class MarkerOptions implements js.Serializable<js.Proxy> {
+ final js.Proxy _proxy;
+
+ MarkerOptions() : this._(new js.Proxy(js.context.Object));
+ MarkerOptions._(this._proxy);
+
+ set position(LatLng position) => _proxy.position = position;
+ set map(GMap map) => _proxy.map = map;
+ set title(String title) => _proxy.title = title;
+
+ js.Proxy toJs() => _proxy;
+}
+
+class Marker implements js.Serializable<js.Proxy> {
+ final js.Proxy _proxy;
+
+ Marker(MarkerOptions options) : this._(new js.Proxy(maps.Marker, options));
+ Marker._(this._proxy);
+
+ js.Proxy toJs() => _proxy;
+}
+
+void main() {
+ final myLatlng = new LatLng(-25.363882,131.044922);
+ final mapOptions = new MapOptions()
+ ..zoom = 4
+ ..center = myLatlng
+ ..mapTypeId = MapTypeId.ROADMAP
+ ;
+ final map = new GMap(query("#map_canvas"), mapOptions);
+
+ final marker = new Marker(new MarkerOptions()
+ ..position = myLatlng
+ ..map = map
+ ..title = "Hello World!"
+ );
+}

Powered by Google App Engine
This is Rietveld 408576698