OpenLayers Layer.Vector with external graphic image overlay - scale help

المشرف العام

Administrator
طاقم الإدارة
I've been banging my head against the monitor. I have this image overlay that has a lot of dynamic features associated with it, which are coming from a JSON file that's updated regularly with live data. I believe I need to use the Layer.Vector class because this is the only layer class (as far as I'm aware) that has the capability to host json data within its 'features' property. I took a look at the Layer.Image class and I just don't think it has what I need to support this overlay.

I have a 478 px image that I'm assigning on externalGraphic within a styleMap class. Currently, I have a function that determines graphic height and graphic width, but it doesn't seem to be scaling accurately, based on comparisons with other data sources.

This is the formula/function:

decide.size = function (feature) { var scale, size, OL_res; OL_res = OpenLayers.map.getResolution(); /************************************************************ This scale value is a magic number. I came up with it over a year ago and it works for certain map resolution but not others. I don't know where I got this number and feel foolish for not leaving myself better documentation. *******************************************************/ scale = 1609.74; size = (size * scale) / OL_res; return size; };Does anyone have any suggests how I can accurately scale this graphic according to the resolution of the map? I must have to multiply by something to get my final size just as pixel units (dividing by resolution is adding map units.)

Thank you. I'm at a loss. Been trying to read source code and see if other people have done something similar, but I've been unable to find anything.



أكثر...
 
أعلى