ThinkGeo.com    |     Documentation    |     Premium Support

JSON properties and ThinkGeo Map layers

Hi,

I am looking for someone to help me in two tasks.

Part 1:

Below is the sample json with properties ‘color_Val’. I am trying to display a multilinestring and color the string depending on the value in color_Val property. Please let me know where am i going wrong.

Sample Json:

  {  
     "geometry":{  
        "coordinates":[  
           [  
              [  
                 -67.129402160644531,
                 18.569900512695312
              ],
              [  
                 -67.126701354980469,
                 18.569900512695312
              ],
              [  
                 -67.1239013671875,
                 18.569799423217773
              ]
           ]
        ],
        "type":"MultiLineString"
     },
     "properties":{  
        "color_Val":"1"
     },
     "type":"Feature"
  },

Sample code:

Dim valStyle As ValueStyle = Nothing
valStyle.ColumnName = “color_Val”
valStyle.ValueItems.Add(New ValueItem(“1”,(LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.YellowGreen,
2, LineDashStyle.Dash, True))))
shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valStyle)

Part 2:
Below is the sample json with properties ‘color_Val’ and ‘text_Val’. I am trying to display a value from ‘text_Val’ and color the string depending on the value in color_Val property. Please let me know where am i going wrong.

{
“geometry”:{
“coordinates”:[
-69.2144,
18.6233
],
“type”:“Point”
},
“properties”:{
“text_Val”:"+",
“color_Val”:“1”
},
“type”:“Feature”
},

Sample Code:

Dim valStyle As ValueStyle = Nothing
valStyle.ColumnName = “color_Val”
valStyle.ValueItems.Add(New ValueItem(“1”, (TextStyles.CreateSimpleTextStyle(“text_Val”, “geographic”, 7,
DrawingFontStyles.Regular, New GeoColor(255, 0, 0)))))
shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valStyle)
shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“text_Val”,
“geographic”, 7, DrawingFontStyles.Regular, GeoColor.StandardColors.White)

Please let me know how to get it working.

Hi Sadana,

Your problem is your code render the map based on shape file, but it looks your data source is JSON.

I am not sure what production you are using, but I think if you want to use the JSON data, you should want convert it to our Feature class, then you can add the feature into our InmemoryFeatureLayer and render it.

Regards,

Ethan

I converted the JSON with properties to shape file and i am only trying to render shape file and read data/ properties from shape file.

Do i still need to convert to Feature class??

Hi Sadana,

If you had converted your JSON to shape file, you don’t need to convert it to Feature again.

It looks your code missed this line:
shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

If that still don’t works, could you please upload the converted sample shape file? Just need a small one for test.

So we can check whether the shape file is converted correct.

Regards,

Ethan

Hi Ethan,

I used the above mentioned and still not working.

i am attaching two shape file. LongDashLineWithColor.Zip and 87253_1.zip

using LongDashLineWithColor.zip I am trying to display a multilinestring and color the line depending on the value in ‘colorstr’ property. Please let me know where am i going wrong.

Similarly, using 87253_1.zip I am trying to display a value from ‘textstr’ and color the string depending on the value in colorstr property.

please let me know where am i going wrong.

LongDashLineWithColor.zip (907 Bytes)

87253_1.zip (4.6 KB)
Thanks,
Sadana

Hi Sadana,

Please view attached sample, wish it’s helpful.

9533.zip (21.1 KB)

Regards,

Ethan

Thanks Ethan

I will try and will get back to you soon.

Regards,
Sadana

Hi Ethan,

Thanks for providing the sample and it worked. YAY!!

one more question i have, is there a way to pass the value of colorstr into GeoColor().

I was thinking of saving red, green, blue values in colorstr. is that possible to pass the value into GeoColor()??

Thanks,
Sadana

Hi Sadana,

If you want to implement that, you should want to override the style and try to do that in the DrawCore function.

The value style only support column name, and you need to hard code(or read from setting file) the color in code.

Regards,

Ethan

Hi Ethan,

Thanku for helping me in this.

I will get back to you if i need any further help.

Regards,
Sadana

Hi Sadana,

I am glad to hear that’s helpful.

Any question please feel free to let us know.

Regards,

Ethan