Skip to content

Instantly share code, notes, and snippets.

@PaulAnnekov
Created December 27, 2015 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulAnnekov/df319b5d58926a196eb5 to your computer and use it in GitHub Desktop.
Save PaulAnnekov/df319b5d58926a196eb5 to your computer and use it in GitHub Desktop.
leaflet-dart-undefined-function-dartium
import 'package:my/leaflet/leaflet.dart' as L;
main() {
var map = L.map('map', new L.MapOptions(
layers: [L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png')],
center: L.latLng(48.45, 31.5),
zoom: 7
));
}
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dev environment</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<link rel="stylesheet" href="/app.css" />
<script async src="app.dart" type="application/dart"></script>
<script async src="packages/browser/dart.js"></script>
</head>
<body>
<div id="map"></div>
</body>
</html>
library L;
import 'package:js/js.dart';
@anonymous
@JS()
class TileLayer {
external factory TileLayer();
}
@anonymous
@JS()
class LatLng {
external factory LatLng(
{double lat,
double lng
});
external double get lat;
external set lat(double v);
external double get lng;
external set lng(double v);
}
@anonymous
@JS()
class MapOptions {
external factory MapOptions(
{List<TileLayer> layers,
LatLng center,
int zoom
});
external List<TileLayer> get layers;
external set layers(List<TileLayer> v);
external LatLng get center;
external set center(LatLng v);
external int get zoom;
external set zoom(int v);
}
@JS()
@anonymous
class LeafletMap {
external factory LeafletMap();
external setView(LatLng center, int zoom);
}
@JS('L.map')
external LeafletMap map(String id, [MapOptions options]);
@JS('L.latLng')
external LatLng latLng(double lat, double lng);
@JS('L.tileLayer')
external TileLayer tileLayer(String urlTemplate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment