Re: [OpenLayers-Users] selecting marker potential bug

2009-06-12 Thread Chris Abraham
Great.  Makes sense.  Thanks.
Chris

On Jun 12, 2009, at 2:47 PM, Christopher Schmidt wrote:

> On Fri, Jun 12, 2009 at 02:19:37PM -0400, Chris Abraham wrote:
>> Hi,
>> I think I have found a bug.  See attached file for a simple test  
>> case.
>>
>> When you click on one of the points (features) a popup will display.
>> Since the feature is selected, it's style changes and it turns blue.
>> This is unexpected.  I would have expected it to keep the default
>> style, that is, for it not to change in appearance.  Is this the
>> desired behavior.  To prevent the appearance change, you can change
>> line 71 to:
>> "default": style, "select": style
>>
>> Please let me know if this is a bug or not.
>
> This is documented behavior.
>
> http://docs.openlayers.org/library/feature_styling.html
>
> The “default” intent has a special role: if the extendDefault
> property of the StyleMap is set to true (default), symbolizers
> calculated for other render intents will extend the symbolizer
> calcualated for the “default” intent. So if we want selected
> features just to have a different size or color, we only have to set a
> single property (in this example: pointRadius).
>
> Basically:
>
>  * If you want things to always look the same, pass a symbolizer
>directly into the StyleMap, not into default.
>  * if you want to control the style when something is selected,
>pass in a 'select' param to the hash
>  * If you are fine with the default selcetion style when applied
>to your 'default' rules, then just pass in default.
>
> -- Chris
>
>> Also, it may be related to this bug http://trac.openlayers.org/ 
>> ticket/
>> 1498.
>>
>> Thanks,
>> Chris
>>
>>
>>
>>
>
>> http://www.w3.org/1999/xhtml";>
>> 
>> OpenLayers Cluster Strategy Threshold
>> > type="text/css" />
>> 
>> 
>> ul {
>> list-style: none;
>> padding-left: 2em;
>> }
>> #reset {
>> margin-left: 2em;
>> }
>> 
>> http://openlayers.org/api/2.8-rc5/ 
>> OpenLayers.js">
>> 
>>
>> // create a semi-random grid of features to be clustered
>> var dx = 3;
>> var dy = 3;
>> var px, py;
>> var features = [];
>> for(var x=-45; x<=45; x+=dx) {
>> for(var y=-22.5; y<=22.5; y+=dy) {
>> px = x + (2 * dx * (Math.random() - 0.5));
>> py = y + (2 * dy * (Math.random() - 0.5));
>> features.push(new OpenLayers.Feature.Vector(
>> new OpenLayers.Geometry.Point(px, py), {x:  
>> px, y: py}
>> ));
>> }
>> }
>>
>> var map, strategy, clusters;
>> function init() {
>> map = new OpenLayers.Map('map');
>> var base = new OpenLayers.Layer.WMS("OpenLayers WMS",
>> ["http://t3.labs.metacarta.com/wms-c/Basic.py";,
>>  "http://t2.labs.metacarta.com/wms-c/Basic.py";,
>>  "http://t1.labs.metacarta.com/wms-c/Basic.py";],
>> {layers: 'satellite'}
>> );
>>
>> var style = new OpenLayers.Style({
>> pointRadius: "${radius}",
>> fillColor: "#ffcc66",
>> fillOpacity: 0.8,
>> strokeColor: "#cc6633",
>> strokeWidth: "${width}",
>> strokeOpacity: 0.8
>> }, {
>> context: {
>> width: function(feature) {
>> return (feature.cluster) ? 2 : 1;
>> },
>> radius: function(feature) {
>> var pix = 2;
>> if(feature.cluster) {
>> pix = Math.min 
>> (feature.attributes.count, 7) + 2;
>> }
>> return pix;
>> }
>> }
>> });
>>
>> strategy = new OpenLayers.Strategy.Cluster();
>>
>> clusters = new OpenLayers.Layer.Vector("Clusters", {
>> strategies: [strategy],
>> styleMap: new OpenLayers.StyleMap({
>> "default": style
>> })
>> });
>> function onSelectFeature(feature) {
>>   var popup = new OpenLayers.Popup.FramedCloud(null,  
>> feature.geometry.getBounds().getCenterLonLat(),
>>null, 'hi',
>>

Re: [OpenLayers-Users] selecting marker potential bug

2009-06-12 Thread Chris Abraham
Alternatively, you can replace lines 69-71 with:
 styleMap: new OpenLayers.StyleMap(
 style
 )

I assume here that since I didn't specify "default" this "style" gets  
set to all options.

Chris


On Jun 12, 2009, at 2:19 PM, Chris Abraham wrote:

> Hi,
> I think I have found a bug.  See attached file for a simple test case.
>
> When you click on one of the points (features) a popup will  
> display.  Since the feature is selected, it's style changes and it  
> turns blue.  This is unexpected.  I would have expected it to keep  
> the default style, that is, for it not to change in appearance.  Is  
> this the desired behavior.  To prevent the appearance change, you  
> can change line 71 to:
> "default": style, "select": style
>
> Please let me know if this is a bug or not.
>
> Also, it may be related to this bug http://trac.openlayers.org/ 
> ticket/1498.
>
> Thanks,
> Chris
>
>
>
>
> ___
> Users mailing list
> Users@openlayers.org
> http://openlayers.org/mailman/listinfo/users

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] selecting marker potential bug

2009-06-12 Thread Christopher Schmidt
On Fri, Jun 12, 2009 at 02:19:37PM -0400, Chris Abraham wrote:
> Hi,
> I think I have found a bug.  See attached file for a simple test case.
> 
> When you click on one of the points (features) a popup will display.   
> Since the feature is selected, it's style changes and it turns blue.   
> This is unexpected.  I would have expected it to keep the default  
> style, that is, for it not to change in appearance.  Is this the  
> desired behavior.  To prevent the appearance change, you can change  
> line 71 to:
> "default": style, "select": style
> 
> Please let me know if this is a bug or not.

This is documented behavior.

http://docs.openlayers.org/library/feature_styling.html

The “default” intent has a special role: if the extendDefault
property of the StyleMap is set to true (default), symbolizers
calculated for other render intents will extend the symbolizer
calcualated for the “default” intent. So if we want selected
features just to have a different size or color, we only have to set a
single property (in this example: pointRadius).

Basically:

 * If you want things to always look the same, pass a symbolizer
   directly into the StyleMap, not into default. 
 * if you want to control the style when something is selected,
   pass in a 'select' param to the hash
 * If you are fine with the default selcetion style when applied
   to your 'default' rules, then just pass in default.

-- Chris

> Also, it may be related to this bug http://trac.openlayers.org/ticket/ 
> 1498.
> 
> Thanks,
> Chris
> 
> 
> 
> 

> http://www.w3.org/1999/xhtml";>
> 
> OpenLayers Cluster Strategy Threshold
>  type="text/css" />
> 
> 
> ul {
> list-style: none;
> padding-left: 2em;
> }
> #reset {
> margin-left: 2em;
> }
> 
>  src="http://openlayers.org/api/2.8-rc5/OpenLayers.js";>
> 
> 
> // create a semi-random grid of features to be clustered
> var dx = 3;
> var dy = 3;
> var px, py;
> var features = [];
> for(var x=-45; x<=45; x+=dx) {
> for(var y=-22.5; y<=22.5; y+=dy) {
> px = x + (2 * dx * (Math.random() - 0.5));
> py = y + (2 * dy * (Math.random() - 0.5));
> features.push(new OpenLayers.Feature.Vector(
> new OpenLayers.Geometry.Point(px, py), {x: px, y: py}
> ));
> }
> }
> 
> var map, strategy, clusters;
> function init() {
> map = new OpenLayers.Map('map');
> var base = new OpenLayers.Layer.WMS("OpenLayers WMS", 
> ["http://t3.labs.metacarta.com/wms-c/Basic.py";,
>  "http://t2.labs.metacarta.com/wms-c/Basic.py";,
>  "http://t1.labs.metacarta.com/wms-c/Basic.py";], 
> {layers: 'satellite'}
> );
> 
> var style = new OpenLayers.Style({
> pointRadius: "${radius}",
> fillColor: "#ffcc66",
> fillOpacity: 0.8,
> strokeColor: "#cc6633",
> strokeWidth: "${width}",
> strokeOpacity: 0.8
> }, {
> context: {
> width: function(feature) {
> return (feature.cluster) ? 2 : 1;
> },
> radius: function(feature) {
> var pix = 2;
> if(feature.cluster) {
> pix = Math.min(feature.attributes.count, 7) + 
> 2;
> }
> return pix;
> }
> }
> });
> 
> strategy = new OpenLayers.Strategy.Cluster();
> 
> clusters = new OpenLayers.Layer.Vector("Clusters", {
> strategies: [strategy],
> styleMap: new OpenLayers.StyleMap({
> "default": style
> })
> });
> function onSelectFeature(feature) {
>   var popup = new OpenLayers.Popup.FramedCloud(null, 
> feature.geometry.getBounds().getCenterLonLat(),
>null, 'hi',
>{size: new 
> OpenLayers.Size(1, 1), offset: new OpenLayers.Pixel(1,-2)},
>