问题标签 [angular-leaflet-directive]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
css - angular random css rotation always moving
I would like to have an img with a random css rotation. I managed to achieve this, but when you move your mouse over the leaftlet map, the img is always spinning around:
http://jsfiddle.net/J03rgPf/mzwwfav4/3/
How can I set a random css only once, so that the getRandRot function is not called again and again?
Angular JS Code:
CSS
angularjs - 在Angular中动态更改Leaflet地图边界?
我正在使用 Angular 传单指令。我有一个菜单,用户可以在其中点击一个选项。每次用户单击一个选项时,地图都会使用两个新标记进行更新,并且应调整边界以使这些标记都可见。标记得到更新,但边界似乎有所不同。用户第一次单击时,边界会更新,但此后每次都不会更新。这是每次用户选择一个选项时调用的代码:
这是我的地图初始化代码:
这是我的地图出现的 HTML:
这不是我的数据的问题,因为标记更新得很好。有任何想法吗?边界的功能与标记的功能不同,这似乎很奇怪。
编辑:
所以下面的代码利用了标准的 Leafleat.js 函数并且可以工作:
如果 angular 指令以相同的方式实现 fitbounds,那就太好了。
angularjs - AngularJS getting coordinate from GeoJSON response
I'm new to AngularJS (and very rusty with javascript) and I can't get this seemingly straightforward action to work.
I have a GeoJSON response from a Django Rest Framework backend as follows (relevant bit only):
I want to get the coordinates to pass to Leaflet either directly or via angular-leaflet-directive to display a simple map with a marker at the centre. I have window.MY_SCOPE set to view the contents of $scope in the console and can access the coordinates using data.features[0].geometry.geometry['coordinates'] and this will display in a browser as text but I can't seem to pass it to an embedded Leaflet script (and it's very unwieldy as a variable), and I work out how to extract the values, either as an array or as pair of variable in an external script. Using a loop seems to be the answer although the query will only return one record and I can't get a loop (or two) to return the coordinates. I've been stuck on this for a while now and can't find an example that matches the situation. I have control of the backend so I can change the output if necessary. Does anyone have any insights into this?
EDIT: as answered by @iH8, I'm not returning valid GeoJSON, in the first instance as it had nested geometries, which I have fixed, but also because I am trying to deliver other information with the GeoJSON data as properties, which doesn't validate.
The answer on the DRF side is that I have nested serializers to include the GeoJSON in the data response using django-rest-framework-gis and having both serializers using GeoFeatureModelSerializer, which creates the nested output below. Changing the model with the property information to GeoModelSerializer presents the geo component as a feature and its associated data as properties but not the nested model. I'll spend a bit of time trying to turn it into a valid GeoJSON object but the answer could ultimately to make multiple requests for the page data, which isn't optimal but may be the simplest solution.
UPDATE: after two weeks of head scratching I have managed to get valid geojson from my queryset using by defining values and using django-geojson's serializer. It isn't pretty but it works. However, trying to extract coordinates in an angular controller still doesn't work.
I've boiled my code down to this:
and this returns correctly as shown in this Plunk: http://plnkr.co/edit/xunAg5?p=preview
but always fails in an angular controller with the error 'Cannot read property '0' of undefined'. The 'data' object can be queried in the console as can $scope.data. There are a couple of similar questions that suggest that data.features[0] is undefined but I don't understand how it shows correctly in the console and in ng-inspector.
leaflet - 如何删除传单地图中的传单标记窗格?
我在传单地图中实现了一个 pin 指针。
如何在以下事件中删除该引脚指针。
请帮我。谢谢..
javascript - 如何在角度forEach中将变量传递给函数调用
我正在使用传单指令在 openStreet 地图上显示地图。要列出所有标记,我的代码如下所示:
在该消息模板中,我正在添加一个带有函数调用的按钮,据我所知,要在模板中传递一个变量,Scope 是解决方案,但是在这里,所有标记上 value.ao 名称不同但 project.ao 相同.. 。(为什么 ????)
当我单击每个标记时,它在数组(anArray)中打开最后一个项目。
如何在每次迭代中绑定范围值?,所以我可以在每个标记上打开正确的项目
leaflet - 如何使用角度传单指令和 geojson 更改传单弹出窗口的偏移量?
我正在使用 angular-leaflet-directive 和 geojson 来使用传单和 mapbox 创建地图标记。标记上的弹出窗口未在标记上正确对齐。
如何更改标记上的偏移量?
angularjs - 传单中未出现标记
我正在尝试从数据库加载位置并将其分配给标记(lat,lng)。但是,当我将新标记推送到标记数组时,标记不会出现在传单地图上。
我正在创建这样的标记。
我能够在控制台中看到具有正确值的 marker.lat 和 marker.lng。它只是没有出现在传单地图中。
我也尝试使用 watchCollection() 但没有运气。
javascript - 角度和传单库错误
当我使用带有 angular-leaflet-directive 的传单地图并尝试添加绘图控件时,这会导致错误。
控制器:
HTML 代码:
Angular给出了这个错误:
错误:ng:areq 错误参数
论据mainMapController
不是。
你能给我一些帮助吗?
谢谢