1
私の質問は、既存のマーカーの緯度と経度をどのように取るかです。私に説明してみましょう:私は、ブラウザ上のページに入力したとき、私はアドレスを使用して、マーカーの位置を表示します。文字列の位置から取られたデフォルトマーカーの緯度と経度を返す
<ng-map ng-if="null != evaluation" default-style="false" zoom="16" center="{{ '{{ getAddress() }}' }}" style="width: 100%; height: 430px;">
<marker centered="true" position="{{ '{{ getMarkerPosition() }}' }}" draggable="true" on-dragend="onMarkerDragEnd($event)"></marker>
</ng-map>
角部:
$scope.getMarkerPosition = function() {
if (!$scope.address.mapPinLocationLatitude || !$scope.address.mapPinLocationLongitude) {
return $scope.getAddress();
}
return [$scope.address.mapPinLocationLatitude, $scope.address.mapPinLocationLongitude]
};
$scope.getAddress = function() {
//building the adress by getting the objects that are used for creating an address object
return streetString + ', ' + address; //streetString will be a string that has the complete address
};
$scope.onMarkerDragEnd = function ($event) {
$scope.address.mapPinLocationLatitude = $event.latLng.lat();
$scope.address.mapPinLocationLongitude = $event.latLng.lng();
uptadeRegions();
};
私はマーカーを移動する場合はLATとログが存在して、 2つの配列を返すgetMarkerPositionメソッドしかし、地図上でマーカーを動かさなければ、緯度と経度をどのように取得するのですか?デフォルトは0で、解決方法はわかりません。ありがとう、
EDIT:
app.controller('MapController',
['$scope', 'NgMap','$state', 'SelectOptionsService', '$rootScope', '$q','GeoCoder',
function ($scope, NgMap, $state, SelectOptionsService, $rootScope, $q, GeoCoder) {
私は正確に 'app.controller( 'TestCtrl1'、['$ scope'、 'GeoCoder'、function($ scop)のようなコントローラ – IleNea
のように注入する方法を正確には知らないe、GeoCoder){}] '、どうやってコントローラを定義しますか? – Fetrarij
関数getAddress()は関数ではないと今言われています。 – IleNea