Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps and DART

I am new to DART. Is it possible to use Google Maps Javascript API on DART? If its not directly possible now, is there any other alternate way?

like image 894
18bytes Avatar asked Apr 14 '12 08:04

18bytes


1 Answers

You can now use google_maps package available on pub. This library allows you to use Google Maps JavaScript API from dart scripts.

Simply add the dependency to your pubspec.yaml

dependencies:
  google_maps: ">=1.0.1 <2.0.0"

Include the Maps API JavaScript using a <script> tag.

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

Then you can use Google Maps from dart scripts. Here's a simple exemple :

import 'dart:html';
import 'package:google_maps/google_maps.dart';

void main() {
  final mapOptions = new MapOptions()
    ..zoom = 8
    ..center = new LatLng(-34.397, 150.644)
    ..mapTypeId = MapTypeId.ROADMAP
    ;
  final map = new GMap(query("#map_canvas"), mapOptions);
}
like image 92
Alexandre Ardhuin Avatar answered Oct 24 '22 03:10

Alexandre Ardhuin