[mapguide-users] layerdefinitionfactory with .NET

padmini godavarthi godavarthi.padmini at gmail.com
Tue Jan 6 01:54:21 EST 2009


Hi,
Thanks for u r reply.
but i didn't get u.how can i do with LayerDefinition-1.2.0.xsd ?


actually my requirement is that i want to load thematic maps dynamically(c#
code) based on some condition..
1)how can i achieve this?
can u plz expain me the procedure for how to doit.


Thanks and Regards,
Padmini.


Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> 0)
> The classes named below can refer either to MaestroAPI classes or Xml 
> tag names.
> The code given is for the MaestroAPI.
> There is no equivalent for the official API, and you will have to do 
> this using Xml
> manipulation.
> 
> Search for a file called LayerDefinition-1.2.0.xsd for a description of 
> such a document.
> 
> 1)
> Xsd:
> C:\Program 
> Files\MapGuideOpenSource2.0\Server\Schema\LayerDefinition-1.2.0.xsd
> MaestroAPI:
> http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI
> 
> 2)
> I have shown that in the sample code.
> 
> 3)
> I have included code?
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> padmini godavarthi skrev:
>> Hi,
>> Thanks for u r reply.But i didnt find PointRuleType anywhere?
>> 1) where can i find this?
>> 2) And how to apply properties to the layer?
>> 3) can u send me the code. 
>> so that it will be very helpful.
>>
>>
>>
>> Thanks and Regards,
>> Padmini
>>
>>
>>
>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>   
>>> I don't know where or what the LayerDefinitionFactory is, but to add 
>>> thematic rules
>>> you simply add a "PointRuleType", "LineRuleType" or "AreaRuleType" to
>>> the
>>> "PointTypeStyleType", "LineTypeStyleType" or "AreaTypeStyleType" 
>>> collection of the
>>> desired scalerange.
>>>
>>> eg:
>>> PointRuleType prt = new PointRuleType();
>>> prt.Filter = "\"ID\" > 100";
>>> //TODO: Set style and other properties
>>>
>>> LayerDefinition ldef; //<-- Assign this
>>> VectorLayerDefintionType vldef = ldef.Item as VectorLayerDefinitionType;
>>> //If you have more than just points, you must itterate the "Items" to 
>>> find the right one
>>> PointTypeStyleType pst = vldef.VectorScaleRange[0].Items[0] as 
>>> PointTypeStyleType;
>>> pst.PointRule.Add(prt);
>>>
>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>
>>>
>>>
>>> padmini godavarthi skrev:
>>>     
>>>> Hi,
>>>> i want to do thematic mapping in .net .for that i suppose to use
>>>> LayerDefinitionFctory .
>>>> how to use it in .net?
>>>>
>>>> can u send me the code in .net
>>>>
>>>>
>>>> Thanks and Regards,
>>>> Padmini
>>>>
>>>>
>>>> m.karam wrote:
>>>>   
>>>>       
>>>>> Hi,
>>>>>
>>>>> Many thanks for you Jackie
>>>>> it works good
>>>>>
>>>>> Regards
>>>>>
>>>>> Karam
>>>>>
>>>>>
>>>>> Jackie Ng wrote:
>>>>>     
>>>>>         
>>>>>> Hi there,
>>>>>>
>>>>>> There is no .NET equivalent to LayerDefintionFactory. You'll have to
>>>>>> port
>>>>>> it over to .net.
>>>>>>
>>>>>> layerdefinitionfactory.php simply takes a bunch of xml templates in
>>>>>> the
>>>>>> "viewerfiles" directory of your web extensions install folder and
>>>>>> fills
>>>>>> in the blanks with the parameters you provide.
>>>>>>
>>>>>> example of CreateAreaRule() in .net:
>>>>>>
>>>>>> class LayerDefinitionFactory
>>>>>> {
>>>>>>     ...
>>>>>>
>>>>>>     public static string CreateAreaRule(string legendLabel, string
>>>>>> filterText, string foreGroudColor)
>>>>>>     {
>>>>>>         StreamReader reader = new
>>>>>> StreamReader("path/to/arearule.templ");
>>>>>>         string areaRuleXml = reader.ReadToEnd();
>>>>>>         string [] values = new string[] { legendLabel, filterText,
>>>>>> foreGroundColor };
>>>>>>         areaRuleXml = Substitute(areaRuleXml, values);
>>>>>>         return areaRuleXml;
>>>>>>     }
>>>>>>     
>>>>>>     ...
>>>>>>     
>>>>>>     static String Substitute(String templ, String[] vals)
>>>>>>     {
>>>>>>         StringBuilder res = new StringBuilder();
>>>>>>         int index = 0, val = 0;
>>>>>>         bool found;
>>>>>>         do
>>>>>>         {
>>>>>>             found = false;
>>>>>>             int i = templ.IndexOf('%', index);
>>>>>>             if(i != -1)
>>>>>>             {
>>>>>>                 found = true;
>>>>>>                 res.Append(templ.Substring(index, i - index));
>>>>>>                 if(i < templ.Length - 1)
>>>>>>                 {
>>>>>>                     if(templ[i+1] == '%')
>>>>>>                         res.Append('%');
>>>>>>                     else if(templ[i+1] == 's')
>>>>>>                         res.Append(vals[val ++]);
>>>>>>                     else
>>>>>>                         res.Append('@');    //add a character illegal
>>>>>> in
>>>>>> jscript so we know the template was incorrect
>>>>>>                     index = i + 2;
>>>>>>                 }
>>>>>>             }
>>>>>>         } while(found);
>>>>>>         res.Append(templ.Substring(index));
>>>>>>         return res.ToString();
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Other CreateXXX functions are variations on the above example.
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> - Jackie
>>>>>>
>>>>>>
>>>>>> m.karam wrote:
>>>>>>       
>>>>>>           
>>>>>>> Hi everybody
>>>>>>>
>>>>>>> How can I use the (layerdefinitionfactory.php) API functions witn
>>>>>>> .NET
>>>>>>> ?
>>>>>>>
>>>>>>> thanks
>>>>>>>
>>>>>>> Karam
>>>>>>>
>>>>>>>         
>>>>>>>             
>>>>>>       
>>>>>>           
>>>>>     
>>>>>         
>>>>   
>>>>       
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/layerdefinitionfactory-with-.NET-tp1809201p2116477.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list