如何在angular-google-map中使标记可拖动?

时间:2015-10-14 13:40:50

标签: javascript angularjs google-maps google-maps-api-3

我想在Map中制作可拖动的地图标记,因此只需将其设为class SettingsTableViewCell: UITableViewCell { @IBOutlet var titleLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() let titleFont = UIFont(name: "ProximaNovaSoft-Regular", size: self.titleLabel.font.pointSize) self.titleLabel.font = titleFont } } 但它没有用。

draggable="true"

1 个答案:

答案 0 :(得分:0)

缺少控制器?

angular.module('mapsApp', [])
.controller('MapCtrl', function ($scope) {

    var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(40.0000, -98.0000),
        mapTypeId: google.maps.MapTypeId.TERRAIN
    }

    $scope.map = new google.maps.Map(document.getElementById('map'), mapOptions);

    $scope.markers = [];

    var infoWindow = new google.maps.InfoWindow();

    var createMarker = function (info){

        var marker = new google.maps.Marker({
            map: $scope.map,
            position: new google.maps.LatLng(info.lat, info.long),
            draggable: true,
            title: info.city
        });
        marker.content = '<div class="infoWindowContent">' + info.desc + '</div>';

        google.maps.event.addListener(marker, 'click', function(){
            infoWindow.setContent('<h2>' + marker.title + '</h2>' + marker.content);
            infoWindow.open($scope.map, marker);
        });

        $scope.markers.push(marker);

    }