ThinkGeo.com    |     Documentation    |     Premium Support

InMemoryFeatureLayer show wrong coordinates

Hi, I’m using InMemoryFeatureLayer to show points I get from a REST endpoint. But all features I add to it are rendered at (0, 0) coordinate.
It works fine if I use the ShapeFileFeatureLayer loading files I created using MapSuiteGisEditor tool.

Here is my code. Am I missing something? Should I add the projection somewhere?

internal Layer GetPointLocations()
    {
        var vertex = new Vertex(-85, 32);

        var feature = new ThinkGeo.MapSuite.Shapes.Feature(vertex, "2424994");
        feature.ColumnValues.Add("Metadata1", "Meta1");
        feature.ColumnValues.Add("Metadata2", "Meta2");

        var features = new List<ThinkGeo.MapSuite.Shapes.Feature>{ feature };

        var featureColumns = new List<FeatureSourceColumn>
        {
            new FeatureSourceColumn("Metadata1"),
            new FeatureSourceColumn("Metadata2")
        };

        var memoryLayer = new InMemoryFeatureLayer(featureColumns, features);
        var icon = Path.Combine(_imagesDirectory, "location-light.png");
        var markerStyle = new PointStyle(new GeoImage(icon));

        memoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = markerStyle;
        memoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        return memoryLayer;
    }

Hi Darlan_Batista,

I create a sample here: 9078.zip (102.8 KB)

It looks works well and the point render in correct position.

I think you can modify the sample to reproduce the problem.

Regards,

Ethan

It works!

I just set the projection to my InMemoryFeatureLayer as you did in your sample:

        Proj4Projection proj4 = new Proj4Projection(Proj4Projection.GetWgs84ParametersString(), Proj4Projection.GetSphericalMercatorParametersString());
        if (!proj4.IsOpen) proj4.Open();
        inMemoryFeatureLayer.FeatureSource.Projection = proj4;

Thank you.

Hi Darlan_Batista,

I am glad to hear that’s helpful.

Regards,

Ethan

Additional Question: I’ll have a map with lots of different objects, some of them might change its position every second and some don’t move at all. I’m using MapSuite Web for WebAPI to render these “static” objects. But the problem is that I need to handle clicks on them to show its details in a pop-up window.

Is there any technique to do it using OpenLayers 3? Some way to hook OpenLayers click events to rendered features on MapSuite Web API?