我有一个表格和地图(ngMap),填写表格并在地图上插入标记后,如果我点击提交,它将保存。但是如果我再添加一个,标记将已经存在于先前坐标的位置。如果我手动重新加载页面,标记将不在地图上。如何在不手动重新加载页面的情况下删除或隐藏。
HTML
<ng-map zoom="13" center="{{coordinates.lat}},{{coordinates.lng}}" map-type-id="TERRAIN">
<marker></marker>
<shape name="polygon" on-click="drawPolygon()" paths={{rectangle}} stroke-color="#ff3232" stroke-opacity="0.8" stroke-weight="2" fill-color="#ff4c4c" fill-opacity="0.35">
</shape>
<drawing-manager on-overlaycomplete="insertMarker()" drawing-control-options="{position: 'TOP_CENTER',drawingModes:['marker']}" markerOptions="{icon:'http://www1.durban.gov.za/beachwater/images/markers/orange-dot.png'}" drawingControl="true" drawingMode="null">
</drawing-manager>
</ng-map>
控制器
$scope.drawingControlOptions = {
position: 'TOP_CENTER',
drawingModes: ['polygon', 'marker']
};
$scope.placesCounter = 0;
$scope.insertMarker = function(e) {
if (e.type == google.maps.drawing.OverlayType.MARKER) {
$scope.placesCounter++;
if ($scope.placesCounter > 1)
e.overlay.setMap(null); //disable marker from diplaying ..
var pos = e.overlay.getPosition();
$scope.markercoordinates = pos.toString();
}
};
而且我也尝试过这样的成功承诺,但没有奏效
$scope.positions= [];
place.coordinates=$scope.positions[0];
并且因为我使用了 ui-router,所以我尝试像这样以编程方式重新加载页面$state.transitionTo('dashboard.places.list', null, { reload: true, inherit: false, notify: true });
,但也没有用。谁能帮帮我