I am the creator of ng-map.
I´m trying to develop a directive in AngularJS to show a Google Maps. I can show the map, but I want to go one step further. My directive will accept coords or an address. In case the coords are set, it will show a marker with them. However if the coords are not available, then it should try to show a marker using the address and Geocode.
My problem is when I try to run the geocode function inside the directive, this request looks asynchronous and the rest of the code is executed before I get the response.
How can I force to execute this request?
Please see my plunker: http://plnkr.co/edit/QRj6jXQYxSRR3CseavQY?p=preview
<div class="span12">
{{center}}
<label>Address</label>
<input type="text" ng-model="completeAddress" class="input-xxlarge input-height-large" placeholder="Type your business address...">
<map id="map_canvas" style="height: 452px; margin-bottom: 20px;"></map>
<button class="btn btn-primary btn-large pull-right" style="margin-bottom: inherit" ng-click="setBusinessLocation()">Save</button>
</div>
You can notice, there is a marker in one city (Gijon) (after geocode), but the map is created before with the center in other city (Getafe).
Thanks, Roberto.