Dylan Mikus
2012-Jun-19 21:25 UTC
[Mapstraction] Setting polyline options in Leaflet and OpenLayers
I''m trying to use Mapstraction to bridge the gap between Google Maps v3, Leaflet, and OpenLayers. Right now, I''m looking at the Polyline.addData method. If I call Polyline.addData({''opacity'': 1.0}) then Google Maps will correctly fill in the polygon, but OpenLayers and Leaflet will not. Where do we actually translate the options passed in? I see that the addData method just calls setOpacity in this case, and all that does is call this.opacity = opacity. Is that all the the code does for this? If that is the case, then there should be a place where we translate these options. I know that the opacity settings are named differently for these three libraries and are not located in the same place in the object structure. If was going to add support for setting opacity, would I case on the API in the setOpacity method in mxn.core? Or would I edit the applyOptions functions in the respective module provider JS files? Thanks, Dylan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20120619/99fc17a4/attachment.htm>
Dylan Mikus
2012-Jun-20 16:17 UTC
[Mapstraction] Setting polyline options in Leaflet and OpenLayers
So, I spent more time looking through the source code. Given the current setup, that you should call addData as normal and it would simply set this.opacity. Then, to update the polygon on the map you would have a function in the Mapstraction object that updates the polygon styles. The issue is that polygons don''t have access to their API, and if Mapstraction objects are the only objects to contain information about their own API, then toggling some global API switch would not work, and thus polygons don''t have anywhere to look for their API data. So, on Mapstraction, you could have a method to update all Polylines, and it would read the API independent Polyline styling and then set the API specific styling. This might be slow if you have a lot of polygons, however, and I haven''t given much thought about how to combat that. - Dylan On Tue, Jun 19, 2012 at 5:25 PM, Dylan Mikus <mikus at rhiza.com> wrote:> I''m trying to use Mapstraction to bridge the gap between Google Maps v3, > Leaflet, and OpenLayers. Right now, I''m looking at the Polyline.addData > method. If I call > > Polyline.addData({''opacity'': 1.0}) > > then Google Maps will correctly fill in the polygon, but OpenLayers and > Leaflet will not. Where do we actually translate the options passed in? I > see that the addData method just calls setOpacity in this case, and all > that does is call this.opacity = opacity. > > Is that all the the code does for this? If that is the case, then there > should be a place where we translate these options. I know that the opacity > settings are named differently for these three libraries and are not > located in the same place in the object structure. > > If was going to add support for setting opacity, would I case on the API > in the setOpacity method in mxn.core? Or would I edit the applyOptions > functions in the respective module provider JS files? > > Thanks, > Dylan >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20120620/f769fa49/attachment.htm>