ng-maps记录纬度经度

时间:2016-03-25 16:03:54

标签: javascript angularjs google-maps ng-map

我使用以下方法在我的网络应用程序中嵌入了Google地图:



<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>
&#13;
&#13;
&#13;

和控制器:

&#13;
&#13;
$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.....");
			}
		}
	};
&#13;
&#13;
&#13;

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

1 个答案:

答案 0 :(得分:0)

解决方法如下:

&#13;
&#13;
<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>
&#13;
&#13;
&#13;

控制器:

&#13;
&#13;
$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
	};
&#13;
&#13;
&#13;