0

我在我的网络应用程序中嵌入了谷歌地图,使用:

<div>
	<map ng-transclude class="google-map" center="map.center" options="map.options">
	<marker position="marker.position" decimals="marker.decimals" options="marker.options" on-click="updatelatlong()"></marker></map>
	</div>

和控制器:

$scope.map = {
		center: [39, -121],
		options: function() {
			return {
				streetViewControl: false,
				scrollwheel: false
			}
		}
	};

	$scope.marker = {
		position: [39, -121],
		decimals: 4,
		options: function() {
			return { draggable: true };
		},
		events:{
			drag:function(e, p, map, points) {
				console.log("dragged.....");
			}
		}
	};

我正在尝试记录与新拖动标记关联的纬度经度。但是,控制权不会交给拖动事件侦听器。

4

1 回答 1

0

解决如下:

<map ng-transclude class="google-map" center="map.center" options="map.options">
	<!--<marker position="marker.position" decimals="marker.decimals" options="marker.options"></marker>-->
		<points coords="points.coords" options="points.options" events="points.events" decimals="points.decimals"></points></map>
	</div>

控制器:

$scope.map = {
		center: [39, -121],
		options: function() {
			return {
				streetViewControl: false,
				scrollwheel: false
			}
		}
	};

$scope.points = {
		coords: [
			[47,-122]
		],
		options: function(coords, properties, i, map) {
			return {
				draggable: true
			}
		},
		events: {
			drag: function(e, point, map, points) {
				$scope.longitude=e.latLng.lng();
				$scope.latitude=e.latLng.lat();
			}
		},
		decimals: 3
	};

于 2016-03-25T16:37:42.697 回答