-1

Googleマップ用のAngularプラグインの下で試しています。

https://ngmap.github.io/

マーカーなしで情報ウィンドウを追加する方法を教えてください。

前もって感謝します

4

1 に答える 1

0

情報ウィンドウによると:

通常、情報ウィンドウをマーカーにアタッチしますが、特定の緯度/経度に情報ウィンドウをアタッチすることもできます

次の例は、情報ウィンドウを特定の緯度/経度にアタッチする方法を示しています。

angular.module('ngMap').run(function($rootScope, NgMap) {
  NgMap.getMap().then(function(map) {
    $rootScope.map = map;
    var iw = map.infoWindows.bar;
    iw.setPosition(new google.maps.LatLng(-25.363882,131.044922));
    map.showInfoWindow('bar');
  });
});
.ng-map-info-window {
    background-color: navy;
    color: #fff;
  }
  .ng-map-info-window div:first-child > div:nth-child(1) {
    border-top-color: navy !important;
  }
  .ng-map-info-window div:first-child > div:nth-child(3) div {
    background-color: transparent !important;
  }
  .ng-map-info-window div:first-child > div:nth-child(4) {
    background-color: transparent !important;
  }
 <script type="text/javascript" src="https://maps.google.com/maps/api/js"></script>
  <script type="text/javascript" src="https://code.angularjs.org/1.3.15/angular.js"></script>
  <script type="text/javascript" src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script> 
<div ng-app="ngMap">
    Info Windows
    <br/> This example displays a marker at the center of Australia. When the user clicks the marker, an info window opens.
    <ng-map default-style="true" center="-25.363882,131.044922" zoom="4">
      <!--marker id="foo" position="-25.363882,131.044922" on-click="map.showInfoWindow('bar')">
      </marker-->
      <info-window id="bar" >
        <div ng-non-bindable>
          <div id="siteNotice"></div>
          <h1 id="firstHeading" class="firstHeading">Uluru</h1>
          <div id="bodyContent">
            <p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large sandstone rock formation in the southern part
              of the Northern Territory, central Australia. It lies 335 km (208 mi) south west of the nearest large town,
              Alice Springs; 450 km (280 mi) by road. Kata Tjuta and Uluru are the two major features of the Uluru - Kata
              Tjuta National Park. Uluru is sacred to the Pitjantjatjara and Yankunytjatjara, the Aboriginal people of the
              area. It has many springs, waterholes, rock caves and ancient paintings. Uluru is listed as a World Heritage
              Site.</p>
            <p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">
            http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>
          </div>
        </div>
      </info-window>
    </ng-map>
  </div>

jsフィドル

于 2016-02-24T20:44:37.373 に答える