Arnd and Eric,<div><br></div><div> Thanks for the quick help. I was thinking that it was looking for the properties off of the vector feature object, and was hoping passing in a different context would allow me to keep the fields on the same level as the coordinates.</div>
<div><br></div><div> The current json document indeed does draw, but not not with the
<span style>addUniqueValueRules</span> set. Perhaps the formatter is creating a vector feature good enough to draw, but not filter.</div><div><br></div><div> The source is from a C# web service call to a MongoDB collection (table in mongo parlance). And performance is impressive, the 3 points was a sample from the original 1800 points (hence a W status thrown in there), which draw faster than the OSM basemap. In fact performance doesn't start to drop off until 30K points, far more than I expected.</div>
<div><br></div><div> Converting the source from a GeometryCollection to a FeatureCollection ins't a problem, but I have to figure out how to create an object from the MongoDB document that has the properties object inside the feature object. Like I said, I was hoping the context would allow me to fake that :-)</div>
<div><br></div><div>Let me see what I can come up with.<br><br><div class="gmail_quote">On Wed, Jan 18, 2012 at 12:14 PM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br><br>On Wednesday, January 18, 2012, John Cole <<a href="mailto:jcole@solidearth.com" target="_blank">jcole@solidearth.com</a>> wrote:<br>
> Hey guys,<br>> I'm trying to use a stylemap on a GeoJson datasource, and want to change the color of the symbol based off of a field in the data.<br>
> My data looks like:<br>> {<br>> "type" : "GeometryCollection",<br>> "geometries" : [{<br>> "type" : "Point",<br>> "_id" : {<br>> "code" : "123",<br>
> "version" : 0<br>> },<br>> "coordinates" : [-86.586502, 34.731189],<br>> "Status" : "W"<br>> }, {<br>> "type" : "Point",<br>> "_id" : {<br>
> "code" : "234",<br>> "version" : 0<br>> },<br>> "coordinates" : <a href="tel:%5B-86.57294326" value="+18657294326" target="_blank">[-86.57294326</a>, <a href="tel:34.73563314" value="+13473563314" target="_blank">34.73563314</a>],<br>
> "Status" : "W"<br>> }, {<br>> "type" : "Point",<br>
> "_id" : {<br>> "code" : "456",<br>> "version" : 0<br>> },<br>> "coordinates" : <a href="tel:%5B-86.45717254" value="+18645717254" target="_blank">[-86.45717254</a>, 34.82754903],<br>
> "Status" : "A"<br>
> }<br>> ]<br>> }<br><br></div></div>I don't think OpenLayers's GeoJSON format can produce OpenLayers.Feature.Vector objects from such a JSON doc. To produce features the GeoJSON format should receive a doc whose root object is of type FeatureCollection. <br>
<div class="im">
<br>><br>> and my style stylemap:<br>> var styleMap = new OpenLayers.StyleMap({<br>> "default": new OpenLayers.Style({<br>> fillOpacity: 0.5,<br>> pointRadius: 5,<br>
> fillColor: "#ee9900"<br>> })<br>> });<br>> <br>> var lookup = {<br>> "S": {fillColor: "red"},<br>> "A": {fillColor: "green"},<br>
> "X": {fillColor: "blue"}<br>> };<br>> styleMap.addUniqueValueRules("default", "Status", lookup);<br>> However, when I apply the addUniqueValueRules, no features are drawn. Tracing through the draw cycle,<br>
> line 117 of Comparison.js which is getting the value of "Status" from the context returns undefined. What do I need to do to get the "Status" into the correct context? <br><br><br></div>For your rules to work "Status" must be a property of the "properties" object in each "feature" object of the GeoJSON doc.<br>
<br>So make sure you have correctly formed feature objects in your layer. Each feature object should a "Status" property in its "attributes" object.<br><br>Hope this helps.<span class="HOEnZb"><font color="#888888"><br>
<br>-- <br>Eric Lemoine<br>
<br>Camptocamp France SAS<br>Savoie Technolac, BP 352<br>73377 Le Bourget du Lac, Cedex<br><br>Tel : 00 33 4 79 44 44 96<br>Mail : <a href="mailto:eric.lemoine@camptocamp.com" target="_blank">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
<br>
</font></span></blockquote></div><br></div>