tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 637 forks source link

featureGroups or some other way to fit groups of markers on the map #215

Closed ranmacar closed 9 years ago

ranmacar commented 10 years ago

Hello!

I am trying to get started with the directive. One of the features I need is fitting groups of markers. This can be accomplished by adding relevant markers to a featureGroup and getting the bounds in Leaflet, and it is rather hard to work with markers as they are created by the directive. This interface seems to be missing from the directive. Is there another way to achieve this kind of functionality?

What would be awesome, is a optional parameter on the Marker object, groups (string or array of strings), which when entered adds the marker to relevant featureGroups (and creates new ones when needed).

Anyone else thinks this is needed/useful? Thanks, Ranmacar

tombatossals commented 10 years ago

Your proposal seems very useful. I'm busy right now, but I will take a look on this when I have more spare time.

In the meantime, if you would like to send a Pull Request I will take a look on it.

ranmacar commented 10 years ago

I am also quite busy now, but should I get my hands on it before you can, I will send my code in. Thanks for all the work so far.

ccrabb commented 10 years ago

You can define LayerGroup (parent of FeatureGroup) overlay layers and set the layer property of a marker already.

Like this:

overlays: { group1: { type: 'group', name: 'MarkerGroup1', visible: true, layerOptions: {

                        }
                    }
                }

$scope.model.markers.push(angular.extend(item, { layer: 'group1', lat: item.Latitude, lng: item.Longitude, message: item.Name, focus: false, draggable: false, popupOptions: { autoPan: false, }, }));

On Wed, Dec 11, 2013 at 2:16 AM, ranmacar notifications@github.com wrote:

I am also quite busy now, but should I get my hands on it before you can, I will send my code in. Thanks for all the work so far.

— Reply to this email directly or view it on GitHubhttps://github.com/tombatossals/angular-leaflet-directive/issues/215#issuecomment-30308513 .

ranmacar commented 10 years ago

Thanks, will look into it. Obvious feature obviously already implemented :+1:

ccrabb commented 10 years ago

You won't have any way to call getBounds out of the box.

You could presumably call .eachLayer(fn()) on the map (after binding the map to your controller scope) but I'm not sure what you'd test to determine if it was the layer you want if you plan on having multiple LayerGroups. There isn't an easy way to get the LayerID with the directive that I can see.

I do think it would be worth improving this feature to get easy access to getBounds and other layer methods. Maybe I'll give it a shot and issue my first pull request ever. Only problem I'll have is writing appropriate unit tests, hmmm...

ranmacar commented 10 years ago

Ok, so there still is work to do. Hope I'll have time to look into it more deeply.

tombatossals commented 10 years ago

You're right @ccrabb , this can be accomplished via the overlays feature which coded @JaumeFigueras some time ago. I have to make a visual demo of it for the main page yet.

It would be great if you could add helpers to better manage the layergroups. I could code the unit tests and the visual demos if you want, or we can make the test together.

ccrabb commented 10 years ago

I realize this is the wrong place to post this, but if someone here has had the same issue I could get this fixed faster

I want to start working on this but I'm having problems running npm install on the project.

I'm on Windows 7 and the karma-coverage install is failing.

1062 error Error: ENOENT, lstat 'C:\Users\Cory\Documents\Git\angular-leaflet-directive\node_modules\karma-coverage\node_modules\istanbul\package.json' 1063 error If you need help, you may report this entire log, 1063 error including the npm and node versions, at: 1063 error http://github.com/isaacs/npm/issues 1064 error System Windows_NT 6.1.7601 1065 error command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" 1066 error cwd C:\Users\Cory\Documents\Git\angular-leaflet-directive 1067 error node -v v0.10.23 1068 error npm -v 1.3.17 1069 error path C:\Users\Cory\Documents\Git\angular-leaflet-directive\node_modules\karma-coverage\node_modules\istanbul\package.json 1070 error fstream_path C:\Users\Cory\Documents\Git\angular-leaflet-directive\node_modules\karma-coverage\node_modules\istanbul\package.json 1071 error fstream_type File 1072 error fstream_class FileWriter 1073 error code ENOENT 1074 error errno 34 1075 error fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26 1075 error fstream_stack Object.oncomplete (fs.js:107:15) 1076 verbose exit [ 34, true ]

virtualandy commented 10 years ago

@ccrabb did you get that fixed? See this issue on npm for similar issues. I think it has/had to do with npm's cache being in need of a good cleaning. From that link, running npm cache clean or deleting your ~/.npm folder (probably something like c:\users\ccrab.npm on windows?) might fix it.

FWIW, consider me :thumbsup: to this feature request.

ccrabb commented 10 years ago

I have not resolved my issue yet. I've created an issue with karma-coverage but haven't heard back yet. I've tried many times to clear my npm cache and am out of ideas.

I've made other changes that I would like to commit as well. Like QuadKey layer support (not so different from Bing layers, really, and I would recommend getting rid of the bing layer support in favor of a more generic QuadKey implementation), and the updating of layer opacity/zIndex values. (You have to call leaflet api methods to update those, unfortunately).

I'm loving this directive and would love to contribute.

On Fri, Dec 13, 2013 at 1:34 PM, Andy notifications@github.com wrote:

@ccrabb https://github.com/ccrabb did you get that fixed? See this issue on npm https://github.com/isaacs/npm/issues/3664 for similar issues. I think it has/had to do with npm's cache being in need of a good cleaning. From that link, running npm cache clean or deleting your ~/.npm folder (probably something like c:\users\ccrab.npm on windows?) might fix it.

FWIW, consider me [image: :thumbsup:] to this feature request.

— Reply to this email directly or view it on GitHubhttps://github.com/tombatossals/angular-leaflet-directive/issues/215#issuecomment-30545426 .

tombatossals commented 10 years ago

Hi @ccrabb,

You're fetching the npm dependencies in a win32 environment, right? This afternoon I will be in a win32 env so I will try to reproduce your error.

In the meantime, you could ignore the fetching of the karma-coverage module (comment the line on package.json), it's not really needed to get things working.

It would be fantastic to get QuadKey layer support, this weekend I have been refactoring the layers.js sub-directive and service, so now it's easier to add a new layer type. I'm with you that we could remove the actual Bing layers support in favor of the QuadKeys layer, it would be great if you could commit this feature.

Thanks for contributing.

tombatossals commented 10 years ago

Hi @ccrabb, I have installed karma-coverage and angular-leaflet-directive in a win32 architecture (windows 8.1) and everything worked well, no error related with karma-coverage.

ccrabb commented 10 years ago

Hey, just got back from a long vacation. I'm on 64bit Windows 7 but will be making another go at getting this working. Will update with my progress but not hopeful so will likely comment out karma-coverage so I can start contributing.

mejackreed commented 10 years ago

Is anyone working on adding the helpers to manage the feature layerGroups? If not I'm happy to tackle it.

tombatossals commented 10 years ago

Hi @mejackreed, I think no one is on this, feel free to work on it. I could help you a little if you have any doubt.

mejackreed commented 10 years ago

@tombatossals Great, I started on something and will push up in a bit so you can take a look. Having a little bit of trouble with the test suite

Splaktar commented 9 years ago

OK, it looks like some work towards this got merged in May (Thanks @mejackreed ) but I don't see an example of how to use Feature Groups with the directive. So it looks like that piece is still pending?

What's the status of the feature after the merge of #364 ? Update: This appears to have been released as part of v0.7.8.

mejackreed commented 9 years ago

@Splaktar I'll try to put together a quick example

nmccready commented 9 years ago

Closing since this is dated. Please comment to re-open.