所以我在这里创建了这个小地图应用程序,正如你可以看到它显示当前的本地化,现在问题是标记将不会显示在当前位置,如果CTRL+U你将看到标记的代码是:
<openlayers ol-center="center" height="400px">
<ol-marker lat="center.lat" lon="center.lon" message="Your current location." ng-model="center" >
</ol-marker>
</openlayers>
Run Code Online (Sandbox Code Playgroud)
该lat="center.lat"和lon="center.lon"在一开始是0,现在如果我硬编码的价值观lat和lon我目前的位置着,当然标记将在我的当前位置显示,但如何动态地更新值?
我正在使用angular.js,openLayers3和openlayers-angular-directive,所以重复我的问题,我如何动态更新标记?
使用$timeout而不是setTimeout. Angular 不知道您正在修改内部范围setTimeout,因此它不会更新视图。
$timeout在内部使用setTimeout(),但也调用$apply()让 Angular 运行摘要。
记住也将其注入控制器中
| 归档时间: |
|
| 查看次数: |
710 次 |
| 最近记录: |