Showing point in map

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Showing point in map

David das Neves

Hey guys,

 

I am totally frustrated now. After reconstructing and trying lots of examples to show a damn point in the map I did not get it to work.

The most example codes are offline and the demo project for the “markup feature” does also not work.

 

Now in the last step I tried to avoid to create the layer programmatically and created it in the Maestro.

But now the code

 

 featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);

 

does not throw an exception and does also not work.

Has someone a solution for me – preferred in c# .Net for the Ajax viewer which knowly works?

 

 

I can´t believe that it is so hard to show a damn point in the map.

 

Here is the last way I have tried – (last one of lots before):

 

    void ShowPoint()
    {
        //---------------------------------------------------//
        // Initialize
        InitializeWebTier();
        sessionId = Request.Params["SESSION"];
        mapName = Request.Params["MAPNAME"];
        MgUserInformation userInfo = new MgUserInformation(sessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
 
        //---------------------------------------------------//
        // Open the map
        MgMap map = new MgMap(siteConnection);
        map.Open(mapName);
 
        MgBatchPropertyCollection batchPropertyCollection = new MgBatchPropertyCollection();
        String featureSourceName = "Library://test/shapes/POIs.FeatureSource";
         //String featureSourceName = "Library://test/layer/POIs.LayerDefinition";
 
        MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
 
        // Make the point
        batchPropertyCollection.Add(MakePoint("Point A", x, y));
 
        // Add the batch property collection to the feature source
        MgInsertFeatures cmd = new MgInsertFeatures("POIs", batchPropertyCollection);
        MgFeatureCommandCollection featureCommandCollection = new MgFeatureCommandCollection();
        featureCommandCollection.Add(cmd);
 
        // Execute the "add" commands
        featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);
  
        // Saving the map
        map.Save(resourceService);
         //map.save
 
        string script = "parent.Refresh();";
 
        ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh",
            script, true);
        ClientScript.RegisterStartupScript(this.GetType(), "Refresh""Refresh();");

}

 

    ///////////////////////////////////////////////////////////////////////////////////
    MgPropertyCollection MakePoint(String name, double x, double y)
    {
        MgPropertyCollection propertyCollection = new MgPropertyCollection();
 
        MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
        MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
 
        MgGeometry geometry = (MgPoint)wktReaderWriter.Read("POINT XY (" + x.ToString().Replace(',''.') + " " + y.ToString().Replace(',''.') + ")");
  
        MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
        MgGeometryProperty geometryProperty = new MgGeometryProperty("Geometry", geometryByteReader);
 
        //propertyCollection.Add(new MgInt32Property("FeatId", 6));
        propertyCollection.Add(new MgStringProperty("Name""Name"));
        propertyCollection.Add(new MgGeometryProperty("Geometry", geometryByteReader));
 
        wktReaderWriter.Dispose();
        agfReaderWriter.Dispose();
        
        return propertyCollection;
    }
 
 
 
Best Regards
 
David

 


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: Showing point in map

Ivan Miličević-3

Hello David,

 

can you please check that you feature source is not set as „read only“?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Das Neves
Sent: Tuesday, January 24, 2012 10:54 AM
To: [hidden email]
Subject: [mapguide-users] Showing point in map

 

Hey guys,

 

I am totally frustrated now. After reconstructing and trying lots of examples to show a damn point in the map I did not get it to work.

The most example codes are offline and the demo project for the “markup feature” does also not work.

 

Now in the last step I tried to avoid to create the layer programmatically and created it in the Maestro.

But now the code

 

 featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);

 

does not throw an exception and does also not work.

Has someone a solution for me – preferred in c# .Net for the Ajax viewer which knowly works?

 

 

I can´t believe that it is so hard to show a damn point in the map.

 

Here is the last way I have tried – (last one of lots before):

 

    void ShowPoint()
    {
        //---------------------------------------------------//
        // Initialize
        InitializeWebTier();
        sessionId = Request.Params["SESSION"];
        mapName = Request.Params["MAPNAME"];
        MgUserInformation userInfo = new MgUserInformation(sessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
 
        //---------------------------------------------------//
        // Open the map
        MgMap map = new MgMap(siteConnection);
        map.Open(mapName);
 
        MgBatchPropertyCollection batchPropertyCollection = new MgBatchPropertyCollection();
        String featureSourceName = "Library://test/shapes/POIs.FeatureSource";
         //String featureSourceName = "Library://test/layer/POIs.LayerDefinition";
 
        MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
 
        // Make the point
        batchPropertyCollection.Add(MakePoint("Point A", x, y));
 
        // Add the batch property collection to the feature source
        MgInsertFeatures cmd = new MgInsertFeatures("POIs", batchPropertyCollection);
        MgFeatureCommandCollection featureCommandCollection = new MgFeatureCommandCollection();
        featureCommandCollection.Add(cmd);
 
        // Execute the "add" commands
        featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);
  
        // Saving the map
        map.Save(resourceService);
         //map.save
 
        string script = "parent.Refresh();";
 
        ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh",
            script, true);
        ClientScript.RegisterStartupScript(this.GetType(), "Refresh""Refresh();");

}

 

    ///////////////////////////////////////////////////////////////////////////////////
    MgPropertyCollection MakePoint(String name, double x, double y)
    {
        MgPropertyCollection propertyCollection = new MgPropertyCollection();
 
        MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
        MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
 
        MgGeometry geometry = (MgPoint)wktReaderWriter.Read("POINT XY (" + x.ToString().Replace(',''.') + " " + y.ToString().Replace(',''.') + ")");
  
        MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
        MgGeometryProperty geometryProperty = new MgGeometryProperty("Geometry", geometryByteReader);
 
        //propertyCollection.Add(new MgInt32Property("FeatId", 6));
        propertyCollection.Add(new MgStringProperty("Name""Name"));
        propertyCollection.Add(new MgGeometryProperty("Geometry", geometryByteReader));
 
        wktReaderWriter.Dispose();
        agfReaderWriter.Dispose();
        
        return propertyCollection;
    }
 
 
 
Best Regards
 
David

 


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: Showing point in map

Ivan Miličević-3
In reply to this post by David das Neves

And please take a look at: http://trac.osgeo.org/mapguide/ticket/649

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Das Neves
Sent: Tuesday, January 24, 2012 10:54 AM
To: [hidden email]
Subject: [mapguide-users] Showing point in map

 

Hey guys,

 

I am totally frustrated now. After reconstructing and trying lots of examples to show a damn point in the map I did not get it to work.

The most example codes are offline and the demo project for the “markup feature” does also not work.

 

Now in the last step I tried to avoid to create the layer programmatically and created it in the Maestro.

But now the code

 

 featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);

 

does not throw an exception and does also not work.

Has someone a solution for me – preferred in c# .Net for the Ajax viewer which knowly works?

 

 

I can´t believe that it is so hard to show a damn point in the map.

 

Here is the last way I have tried – (last one of lots before):

 

    void ShowPoint()
    {
        //---------------------------------------------------//
        // Initialize
        InitializeWebTier();
        sessionId = Request.Params["SESSION"];
        mapName = Request.Params["MAPNAME"];
        MgUserInformation userInfo = new MgUserInformation(sessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
 
        //---------------------------------------------------//
        // Open the map
        MgMap map = new MgMap(siteConnection);
        map.Open(mapName);
 
        MgBatchPropertyCollection batchPropertyCollection = new MgBatchPropertyCollection();
        String featureSourceName = "Library://test/shapes/POIs.FeatureSource";
         //String featureSourceName = "Library://test/layer/POIs.LayerDefinition";
 
        MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
 
        // Make the point
        batchPropertyCollection.Add(MakePoint("Point A", x, y));
 
        // Add the batch property collection to the feature source
        MgInsertFeatures cmd = new MgInsertFeatures("POIs", batchPropertyCollection);
        MgFeatureCommandCollection featureCommandCollection = new MgFeatureCommandCollection();
        featureCommandCollection.Add(cmd);
 
        // Execute the "add" commands
        featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);
  
        // Saving the map
        map.Save(resourceService);
         //map.save
 
        string script = "parent.Refresh();";
 
        ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh",
            script, true);
        ClientScript.RegisterStartupScript(this.GetType(), "Refresh""Refresh();");

}

 

    ///////////////////////////////////////////////////////////////////////////////////
    MgPropertyCollection MakePoint(String name, double x, double y)
    {
        MgPropertyCollection propertyCollection = new MgPropertyCollection();
 
        MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
        MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
 
        MgGeometry geometry = (MgPoint)wktReaderWriter.Read("POINT XY (" + x.ToString().Replace(',''.') + " " + y.ToString().Replace(',''.') + ")");
  
        MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
        MgGeometryProperty geometryProperty = new MgGeometryProperty("Geometry", geometryByteReader);
 
        //propertyCollection.Add(new MgInt32Property("FeatId", 6));
        propertyCollection.Add(new MgStringProperty("Name""Name"));
        propertyCollection.Add(new MgGeometryProperty("Geometry", geometryByteReader));
 
        wktReaderWriter.Dispose();
        agfReaderWriter.Dispose();
        
        return propertyCollection;
    }
 
 
 
Best Regards
 
David

 


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

AW: Showing point in map

David das Neves

Ah thank you for the hint.

 

After the mgServer.exe was holding about 1,5GB and crashed I had to restart it.

 

And then - after I built in the result value to see if the point is created correctly it gave me back that it worked.

And after a look on the map – it worked really! ;)

 

Greetings

 

David

Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Ivan Milicevic
Gesendet: Dienstag, 24. Januar 2012 11:04
An: MapGuide Users Mail List
Betreff: [mapguide-users] RE: Showing point in map

 

And please take a look at: http://trac.osgeo.org/mapguide/ticket/649

 

From: [hidden email] [hidden email] On Behalf Of David Das Neves
Sent: Tuesday, January 24, 2012 10:54 AM
To: [hidden email]
Subject: [mapguide-users] Showing point in map

 

Hey guys,

 

I am totally frustrated now. After reconstructing and trying lots of examples to show a damn point in the map I did not get it to work.

The most example codes are offline and the demo project for the “markup feature” does also not work.

 

Now in the last step I tried to avoid to create the layer programmatically and created it in the Maestro.

But now the code

 

 featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);

 

does not throw an exception and does also not work.

Has someone a solution for me – preferred in c# .Net for the Ajax viewer which knowly works?

 

 

I can´t believe that it is so hard to show a damn point in the map.

 

Here is the last way I have tried – (last one of lots before):

 

    void ShowPoint()
    {
        //---------------------------------------------------//
        // Initialize
        InitializeWebTier();
        sessionId = Request.Params["SESSION"];
        mapName = Request.Params["MAPNAME"];
        MgUserInformation userInfo = new MgUserInformation(sessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
 
        //---------------------------------------------------//
        // Open the map
        MgMap map = new MgMap(siteConnection);
        map.Open(mapName);
 
        MgBatchPropertyCollection batchPropertyCollection = new MgBatchPropertyCollection();
        String featureSourceName = "Library://test/shapes/POIs.FeatureSource";
         //String featureSourceName = "Library://test/layer/POIs.LayerDefinition";
 
        MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
 
        // Make the point
        batchPropertyCollection.Add(MakePoint("Point A", x, y));
 
        // Add the batch property collection to the feature source
        MgInsertFeatures cmd = new MgInsertFeatures("POIs", batchPropertyCollection);
        MgFeatureCommandCollection featureCommandCollection = new MgFeatureCommandCollection();
        featureCommandCollection.Add(cmd);
 
        // Execute the "add" commands
        featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);
  
        // Saving the map
        map.Save(resourceService);
         //map.save
 
        string script = "parent.Refresh();";
 
        ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh",
            script, true);
        ClientScript.RegisterStartupScript(this.GetType(), "Refresh""Refresh();");

}

 

    ///////////////////////////////////////////////////////////////////////////////////
    MgPropertyCollection MakePoint(String name, double x, double y)
    {
        MgPropertyCollection propertyCollection = new MgPropertyCollection();
 
        MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
        MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
 
        MgGeometry geometry = (MgPoint)wktReaderWriter.Read("POINT XY (" + x.ToString().Replace(',''.') + " " + y.ToString().Replace(',''.') + ")");
  
        MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
        MgGeometryProperty geometryProperty = new MgGeometryProperty("Geometry", geometryByteReader);
 
        //propertyCollection.Add(new MgInt32Property("FeatId", 6));
        propertyCollection.Add(new MgStringProperty("Name""Name"));
        propertyCollection.Add(new MgGeometryProperty("Geometry", geometryByteReader));
 
        wktReaderWriter.Dispose();
        agfReaderWriter.Dispose();
        
        return propertyCollection;
    }
 
 
 
Best Regards
 
David

 


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users