将angularjs ui.map与geo location api集成

时间:2014-03-11 06:04:21

标签: angularjs google-maps geocoding google-geolocation

我正在使用 http://jsfiddle.net/xSPAA/371/

//Add the requried module 'angular-ui' as a dependency
angular.module('maptesting', ['ui.map','ui.event']);

function MapCtrl($scope) {
    var ll = new google.maps.LatLng(45, -73);
    $scope.mapOptions = {
        center: ll,
        zoom: 8,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    //Markers should be added after map is loaded
    $scope.onMapIdle = function() {
        if ($scope.myMarkers === undefined){    
            var marker = new google.maps.Marker({
                map: $scope.myMap,
                position: ll
            });
            $scope.myMarkers = [marker, ];
        }
    };

    $scope.markerClicked = function(m) {
        window.alert("clicked");
    };

}

plunker显示谷歌地图。我需要显示用户将在文本框中输入的特定位置图。

我该怎么做?

我是否需要使用Geo Location API?

任何人都可以提供示例代码或plunker吗?

1 个答案:

答案 0 :(得分:3)