[mapguide-users] Working with labels in map viewer
Kenneth Skovhede, GEOGRAF A/S
ks at geograf.dk
Thu Aug 20 10:26:25 EDT 2009
You would have to have a layer with labels.
You do this by assigning an empty style for the point, and then set the
label style.
This will place labels where the points are, but does not show the
points themselves.
For the layer datasource, simply point to the datasource that contains
the label positions as points.
Whenever you want to display labels, simply turn on the layer.
You may want some logic to ensure that the label layer follows the
actual layer (the one with data).
If your layer only stores polygons, and your datasource supports mixed
geometry, you can
display the data and labels using a single layer.
If your datasource is ODBC (which only supports points), you can simply
have the x,y values stored,
and update them with SQL.
Otherwise you have to use the MapGuide FDO wrapper, which has a bit step
learning curve (MgFeatureService).
The problem would be the "select and move" part, as the AJAX viewer has
no support for that.
You could turn on the point style, and make them selectable.
The user can then select a point, click a "move" button, and click at
the new location.
A bit crude, but it would work.
As I mentioned, OpenLayers has a much more refined way of doing this:
http://openlayers.org/dev/examples/drag-feature.html
and
http://openlayers.org/dev/examples/modify-feature.html
Regards, Kenneth Skovhede, GEOGRAF A/S
mighty_duck skrev:
> Hello,
>
> thanks for reply
>
> so, does that mean , for example, that I can keep coordinates of label in
> database and use them when I want to show labels on map? And if I would like
> to be able to change position of those labels...I would need to implement my
> own "labeling" depending on the coordinates from database???
>
> Im using AJAX viewer.
>
> regards
>
>
>
> Kenneth Skovhede, GEOGRAF A/S wrote:
>
>> You have very little control over labels, they are automatically placed
>> on top of the objects the label.
>> You have some offset and rotation, but it is difficult to use for
>> absolute positioning.
>>
>> I would recommend that you use points (in same datasource or seperate)
>> and use those to
>> position the labels correctly.
>>
>> There are no interactive editing of labels or features in the AJAX viewer.
>> If you use OpenLayers (or Fusion), you could extract the points
>> as a vector layer, which can then be manipulated and has mouse events.
>>
>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>
>>
>>
>> mighty_duck skrev:
>>
>>> Hello,
>>>
>>> Does anyone know is it possible to work with labels im map viewer? I need
>>> something like be able to move labels on the map with mouse moving(catch
>>> label with mouse and change location of label)? Is is possible to do with
>>> javascript?
>>>
>>> thanks in advance
>>>
>>> regards
>>>
>>>
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090820/4ed5a52f/attachment.html
More information about the mapguide-users
mailing list