a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Apache License 2.0
130 stars 66 forks source link

Unable to open second instance of map #51

Closed vasner closed 6 years ago

vasner commented 6 years ago

I have an issue with opening second instance on map.

screen shot 2018-02-08 at 19 08 56

Second instance loss position and controls. All other instance have the same issue. If make it FullScreen buttons are back.

Code is following:

    final mapOptions = new gmap.MapOptions()
      ..zoom = 8
      ..disableDoubleClickZoom = true
      ..center = new gmap.LatLng(41.850033, -87.6500523);

    map = new gmap.GMap(mapRoot, mapOptions);

One more thing if I include the Maps API JavaScript using a script tag in div with each instance it fixes focus, but controls are still missed.

a14n commented 6 years ago

I cannot reproduce your issue. The following code works and I see 2 maps.

<!DOCTYPE html>
<html>

<head>
  <title>Simple Map</title>
  <meta name="viewport"
        content="initial-scale=1.0, user-scalable=no">
  <meta charset="utf-8">
  <style>
    html,
    body {
      height: 100%;
      margin: 0px;
      padding: 0px
    }

    #map-canvas1,
    #map-canvas2 {
      height: 50%;
      margin: 0px;
      padding: 0px
    }
  </style>
</head>

<body>
  <div id="map-canvas1"></div>
  <div id="map-canvas2"></div>

  <script src="http://maps.googleapis.com/maps/api/js"></script>
  <script type="application/dart"
          src="page.dart"></script>
  <script src="packages/browser/dart.js"></script>
</body>

</html>
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);
  new GMap(document.getElementById("map-canvas1"), mapOptions);
  new GMap(document.getElementById("map-canvas2"), mapOptions);
}

Please re-open with a simple reproduction code if the issue is not in your code.