[mapguide-users] Autozoom and mark

Ran Mahiru rmahiru_jane5 at yahoo.com
Tue Apr 7 19:27:35 EDT 2009


Thank's Kenneth, I think the error I keep getting is that the runtime map does not exist yet?

Code fragments:
===============

The viewer is activated at the bottom of the code by the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>TEST</title>
    
</head>


<frameset >

	<frame id="viewerFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="http://localhost/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=<%=sessionId%>&WEBLAYOUT=<%=sesslayout%>">
</frameset>


I created the map via:

        Dim map As MgMap = New MgMap
        map.Create(resourceSrvc, mapid, "DemoMap") ' mapid is the resource identifier for the map definition 
        Dim layers = map.GetLayers()

Because I kept getting an error when I tried to open the map...

Further down (after setting up the layer definition) I add it to the map:


        'Create the layer definition
        layerDefContent = BuildLayerDefinitionContent(mrkrDataS, featureName, "")
        Dim rnull As MgByteReader
        
        resourceSrvc.SetResource(mrkrLD_ID, layerDefContent, rnull)
        
        Dim mylegendName = MgLocalizer.GetString("MARKERLAYER", locale)
        Dim layer = New MgLayer(mrkrLD_ID, resourceSrvc)
        layer.SetDisplayInLegend(True)
        layer.SetLegendLabel(mylegendName)
        layers.Insert(0, layer)
        
        'create a feature representing this segment and insert it into the data source
            
        Dim mrkrProps = New MgPropertyCollection
        
        Dim TipProp = New MgStringProperty("TXTDISP", "")
        mrkrProps.Add(TipProp)

        Dim URLProp = New MgStringProperty("URLLINK", "")
        mrkrProps.Add(URLProp)

        Dim agf = New MgAgfReaderWriter()
        Dim geomReader = agf.Write(geom)
        Dim ngeomProp = New MgGeometryProperty("GEOM", geomReader)
        mrkrProps.Add(ngeomProp)

        Dim cmd As MgInsertFeatures = New MgInsertFeatures("Marker", CType(mrkrProps, MgPropertyCollection))
        Dim commands = New MgFeatureCommandCollection()
        commands.Add(cmd)
        featureSrvc.UpdateFeatures(mrkrDS_ID, commands, False)

The feature insertion works since I extracted the session SDF to check. After that the code simply extracts the weblayout, changes the starting center x, y and sets a session weblayout.

One way I managed to get this work is have the add marker code be run in a hidden frame AFTER the map has been loaded in the main frame. But is there a better way?

Thanks again.

>If you have the FeatureSource and the LayerDefinition ready,
>you have to insert the layer into the runtime map, and call Refresh() on 
>the client.
>
>You may also need to insert the temporary feature into the FeatureSource.
>
>Does this help you, or do you need further instructions?
>If so, try posting a code fragment that explains what you have,
>and where you get stuck.
>
>(And yes, it is indeed possible).
>
>Regards, Kenneth Skovhede, GEOGRAF A/S
>
>
>
>Ran Mahiru skrev:
>> Hi all, new to Mapguide Enterprise and a former Mapgudie 6.5 user...
>>
>> I've managed to get the ajaxviewer to load a map at a preset center and zoom by changing the user session's weblayout before display but now I'm trying to add a feature source from a template and add a feature before display as well (to create a temporary marker). Is this even possible?
>>
>> I've managed to succesfully create a marker feature source and layer definition for the session, I think but am at a loss as to how to proceed.
>>
>> Help? ^^;;


      


More information about the mapguide-users mailing list