Google maps setCenter is not centering the map correctly
ngmap recently added 'custom-marker' for this kind of purpose.
With custom-marker
, you can have fully working marker with html. It also responds to all events click, mouseover using google maps API.
This is the example.
https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/custom-marker-2.html
And this is the code required, https://github.com/allenhwkim/angularjs-google-maps/blob/master/testapp/custom-marker-2.html.
As you see in the code, there is no Javascript required.
To center a marker, all the time, all you need to do is to add on-center-changed="centerCustomMarker()"
to your map directive, and the following to your controller.
$scope.centerCustomMarker = function() { $scope.map.customMarkers.foo.setPosition(this.getCenter()); }
I try different approach than you asked, but it may worth a try.
GitHub: https://github.com/allenhwkim/angularjs-google-maps
FYI, I am the creator of ngmap
.