<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=xxxxxxxxxxxxxxxxxx&sensor=false"></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/underscore-min.js'></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/angular-google-maps.min.js'></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/app.js'></script>
<div ng-controller="MyCtrl">
<div class="row">
<div class="col-sm-6">
<google-map
id="map-canvas"
center="map.center"
zoom="map.zoom"
draggable="true"
options="map.options"
control="map.control"
>
<marker coords="map.marker">
</marker>
</google-map>
</div>
<div class="col-sm-6">
<form class="form" role="form">
<div class="form-group">
<label class="control-label">Address</label>
<input type="text" class="form-control" ng-model="address">
</input>
</div>
<button ng-click="codeAddress(address)" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
var mapApp = angular.module('googleMapApp', ['google-maps','ui.bootstrap']);
mapApp.controller("MyCtrl", function ($scope) {
angular.extend($scope, {
map: {
center: {
latitude: 35.681382,
longitude: 139.766084
},
options: {
maxZoom: 20,
minZoom: 3
},
zoom: 16,
control: {},
marker: {}
},
address: ''
});
$scope.codeAddress = function (address) {
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
$scope.map.control.getGMap().setCenter(results[0].geometry.location);
$scope.map.marker.latitude = results[0].geometry.location.lat();
$scope.map.marker.longitude = results[0].geometry.location.lng();
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
return;
};
});
Could you help me? Im trying to implement this example in plnkr and this is what ive got:
http://plnkr.co/edit/kYp5teUY4sndMbRxK8kV?p=preview