javascript - latitude and longitude not saved google maps api -
i'm trying latitude , longitude address google maps api , don't how. map working getting address there way address take lat , lon? following code working:
<ng-map default-style="false" zoom="16" center="{{ '{{ getaddress() }}' }}" style="width: 100%; height: 430px;"> <marker centered="true" position="{{ '{{ getmarkerposition() }}' }}" draggable="true" on-dragend="onmarkerdragend($event)"></marker> <shape ng-if="showregions" ng-repeat="shape in regions" (...) </shape> </ng-map>
and js:
$scope.getmarkerposition = function () { if (!$scope.address.mappinlocationlatitude || !$scope.address.mappinlocationlongitude) { return $scope.getobjectiveaddress(); } return [$scope.address.mappinlocationlatitude, $scope.address.mappinlocationlongitude] };
the problem mappinlocationlatitude , long null, in database not salved , don't know why..
$scope.getaddress = function () { var address = "..."; (here concatenate string address values(street, number, etc , returned) return streetstring + ', ' + address; }; $scope.onmarkerdragend = function ($event) { $scope.address.mappinlocationlatitude = $event.latlng.lat(); $scope.address.mappinlocationlongitude = $event.latlng.lng(); $scope.updateregions(); };
so, question is, idea how latitude , long , example if write: map displayed correctly?
<marker centered="true" position="{{ '{{ [address.mappinlocationlatitude, address.mappinlocationlongitude]}}' }}" draggable="true" on-dragend="onmarkerdragend($event)"></marker>
$.getjson( { url : 'https://maps.googleapis.com/maps/api/geocode/json', data : { sensor : false, address : address }, success : function( data, textstatus ) { console.log( textstatus, data ); }
} );
similar question on stack here
Comments
Post a Comment