在有角度的谷歌地图中使用鼠标移动标记
Move markers using mouse in angular google maps
我正在做一个有角度的项目。它包含一个使用angular-google-maps的谷歌地图。因此,在这个地图上,用户可以添加许多markers
。
app.js
angular.module('mapAngular', ['uiGmapgoogle-maps'])
.controller('MainCtrl', function($scope) {
angular.extend($scope, {
map: {
center: {
latitude: 42.3349940452867,
longitude: -71.0353168884369
},
zoom: 11,
markers: [],
events: {
click: function(map, eventName, originalEventArgs) {
var e = originalEventArgs[0];
var lat = e.latLng.lat(),
lon = e.latLng.lng();
var marker = {
id: Date.now(),
coords: {
latitude: lat,
longitude: lon
}
};
$scope.map.markers.push(marker);
console.log($scope.map.markers);
$scope.$apply();
}
}
}
});
});
HTML
<div>
<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" events="map.events">
<ui-gmap-marker ng-repeat="m in map.markers" coords="m.coords" icon="m.icon" idkey="m.id"></ui-gmap-marker>
</ui-gmap-google-map>
</div>
地图将显示所有添加的标记。我需要一个功能来动态移动这个标记使用鼠标。请给我一个有价值的指导方针?感谢
Plunker
通过在<ui-gmap-marker>
指令中赋予options="{draggable:true}"
来解决问题。
<ui-gmap-marker ng-repeat="m in map.markers" coords="m.coords" icon="m.icon" idkey="m.id" options="{draggable:true}" >
</ui-gmap-marker>
相关文章:
- js:停止鼠标移动
- Zingchart-平移键和鼠标移动
- 在鼠标上触发鼠标移动'的当前位置
- 当用户将鼠标移到屏幕/图表上时,自动滚动将暂停.如果鼠标移动停止,自动滚动将再次恢复
- 如何在谷歌地图上用鼠标移动标记
- 如何在鼠标移动事件时更改图像的窗口中心和宽度
- 如何模仿鼠标移动和事件
- 鼠标点击不会'不起作用,鼠标移动可以
- 有没有办法提高鼠标移动的分辨率
- 如何在JS中随机化backgroundPosition而不使用鼠标移动来制作万花筒的动画
- 如何使用onmousemove函数在每次鼠标移动时更改背景图像
- 使用jQuery/CSS设置的鼠标光标在鼠标移动之前不会更改
- 在谷歌地图中用鼠标移动标记
- 在HTML5画布中绘制鼠标移动的半透明线条
- 如何使用Protractor/Senium将鼠标移动到任意点
- 防止鼠标移动对elementFromPoint的攻击
- 如果鼠标悬停得很快,Jquery鼠标移动会错过一些单元格
- 检查人员是否通过鼠标移动离开网站
- 使用鼠标移动操作选择选项
- 如何在D3Javascript中将鼠标移动到节点上时显示和隐藏节点