您好我是html和angularjs的新手,我在谷歌地图标记上做了一个dmeo,我成功地在地图上得到了标记,但现在我想在该标记上放置一个信息,我搜索了很多东西但是不适合我的情况,所以任何人都可以帮助我如何在地图标记上放置信息,我的代码如下。 的 HTML
int next = num + 1;
if (next > 2) next = 0;
sem_wait(sems[num]);
/* your code, accessing inp[num] */
sem_post(sems[next]);
JS
<div class="mapclass">
<ons-row class="app-map">
<ons-col>
<map center="[{{lat}}, {{lng}}]">
<marker ng-model
position="[{{lat}}, {{lng}}]"
title= "{{tittle}}"
animation="Animation.BOUNCE"
visible="true" ></marker>
</map>
</ons-col>
</ons-row>
</div>
答案 0 :(得分:1)
<div id="main-content">
<div ng-controller="EventSimpleCtrl">
<map zoom="4" center="-25.363882, 131.044922">
<marker position="-25.363882, 131.044922" on-click="click()" title="Click to zoom"></marker>
</map>
</div>
</div>
<script>
var app = angular.module('myapp', ['ngMap']);
app.controller('EventSimpleCtrl', ['$scope', '$timeout', function($scope, $timeout) {
var marker, map;
$scope.$on('mapInitialized', function(evt, evtMap) {
map = evtMap;
marker = map.markers[0];
// this one is if you want to keep an hardcoded <info-window>
// var infoWindow = map.infoWindows[0];
});
$scope.click = function(event) {
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent('Testing');
infoWindow.open(map, marker);
}
}]);
</script>
注意:强>
我猜您正在使用此库http://ngmap.github.io,因此,从DOCs开始,您可以通过两种方式获得info-windows,一种是将标记直接放入options 1}}这样的标签:
<map>
并像这样访问
<info-window id="foo" position="current-location" visible="true"> Some Text Here </info-window>
获得它之后就可以像使用普通的 GMAP API V3一样使用它
答案 1 :(得分:0)
jsfiddle显示谷歌地图和标记,点击标记,它将显示infowindow:
<div ng-app="mapsApp" ng-controller="MapCtrl">
<div id="map"></div>
<div id="class" ng-repeat="marker in markers | orderBy : 'title'">
<a href="#" ng-click="openInfoWindow($event, marker)">{{marker.title}}</a>
</div>
</div>