Closed StilgarBF closed 11 years ago
You need to add the layer to the layer chooser as well. That could be done directly, but there's a utility function that will do this for you
window.addLayerGroup('LAYER_NAME', LAYER_GROUP, true);
the 3rd parameter is true/false for if you want the layer to default to on or off
Also, this will handle saving the layer state, so next time you load IITC it remains the same.
Had done this in the first place, as said before "The option shows up, but does not toggle the layer."
window.addLayerGroup('Portal suggestions', window.plugin.portalSuggestions.markerLayerGroup, true);
I'm a bit confused. Because it seems as if I have done the same things that have been done in other plugins. The only difference I can see is that my layer is created by L.geoJson.
Maybe I have to set up another dummy plugin to check that.
If you want to give the plugin a try . it is linked above. Focus on "Nürnberg" / Nurenberg Germany and trigger the load of the suggestions with the link in the toolbox. - seems to work fine, but I can not hide the layer.
OK, had a closer look.
however, step 3 doesn't replace the layer in the chooser with the new geoJson layer - the layer chooser still holds onto the blank layer.
What you need to do instead is, rather than replacing your blank LayerGroup with the getJson response, you need to ADD your layer returned to the existing layer group.
i.e. instead of
window.plugin.portalSuggestions.markerLayerGroup = L.geoJson(data,
........
}).addTo(map);
do
window.plugin.portalSuggestions.markerLayerGroup.addLayer ( L.geoJson(data,
........
}));
Thanks - that sounds like the problem.
edit: worked perfectly. thanks again.
In context of that plugin: Do you want new plugins as pullrequests to this repo? There are not all available plugins in the plugin-folder.
I do accent new plugins, with some restrictions:
pull requests are preferred, but I'll take it in other forms too if it's easier.
I'm not sure where to find help with a developmen-related question, so I try my luck here.
I'm working on a plugin to show portals that have been suggested on the map. The data is fetched with jsonp from my site and than processed as geojson. It works so far, but I want to add a new option to the layer-group palette. The option shows up, but does not toggle the layer.
The layer has been created with
When trying to remove the layer from the console it works with
What am I doing wrong here?
The plugin can be reviewed in my fork: https://github.com/StilgarBF/ingress-intel-total-conversion/blob/gh-pages/plugins/portal-suggestions.user.js