ThinkGeo.com    |     Documentation    |     Premium Support

Layer not coming when adding from client side

Hello @Ethan, this is the code
I’m trying to add a layer with geoJson It’s not coming bt it’s showing in olMap.layers object.

var featurecollection = {
“type”: “FeatureCollection”,
“features”: [
{“geometry”: {
“type”: “GeometryCollection”,
“geometries”: [
{
“type”: “LineString”,
“coordinates”:
[[11.0878902207, 45.1602390564],
[15.01953125, 48.1298828125]]
},
{
“type”: “Polygon”,
“coordinates”:
[[[11.0878902207, 45.1602390564],
[14.931640625, 40.9228515625],
[0.8251953125, 41.0986328125],
[7.63671875, 48.96484375],
[11.0878902207, 45.1602390564]]]
},
{
“type”:“Point”,
“coordinates”:[15.87646484375, 44.1748046875]
}
]
},
“type”: “Feature”,
“properties”: {}}
]
};
var geojson_format = new OpenLayers.Format.GeoJSON();
var vector_layer = new OpenLayers.Layer.Vector();
olMap.addLayer(vector_layer);
vector_layer.addFeatures(geojson_format.read(f));

Hi Bibek,

Please visit our client API documentation here: Client API Documentation for Map Suite Web Edition

You can found “How To Use OpenLayers’ API” about it.

Regards,

Ethan

actually this code is working in openlayer demo project.

Hi Bibek,

I think the reason is you hadn’t add the layer you crated into our map.

Our client side is based on OpenLayers, but you also need to add the object into our map after you created OpenLayers object.

Regards,

Ethan

Openlayers Example.zip (927.1 KB)EditOverlayStyles.zip (1.6 MB)

var OnMapCreated = function(map){
var featurecollection = {
“type”: “FeatureCollection”,
“features”: [
{“geometry”: {
“type”: “GeometryCollection”,
“geometries”: [
{
“type”: “LineString”,
“coordinates”:
[[11.0878902207, 45.1602390564],
[15.01953125, 48.1298828125]]
},
{
“type”: “Polygon”,
“coordinates”:
[[[11.0878902207, 45.1602390564],
[14.931640625, 40.9228515625],
[0.8251953125, 41.0986328125],
[7.63671875, 48.96484375],
[11.0878902207, 45.1602390564]]]
},
{
“type”:“Point”,
“coordinates”:[15.87646484375, 44.1748046875]
}
]
},
“type”: “Feature”,
“properties”: {}}
]
};
var geojson_format = new OpenLayers.Format.GeoJSON();
var vector_layer = new OpenLayers.Layer.Vector();
map.addLayer(vector_layer);
vector_layer.addFeatures(geojson_format.read(f));
}

I tried like this also . It’s not working . It’s showing in the overlay switcher . But shape is not showing in the map.

Hi Bibek,

I tested your code, it works well.

I think the reason is you hadn’t set the correct current extent.

Please try my sample here:

9229.zip (174.0 KB)

Regards,

Ethan

Thanks @Ethan , Now the problem is it’s add behind all the layers . the Zindex is 520 . Please hrlp me to sort it out.

Hi Bibek,

Have you tried to set its zindex for example: layer.setZIndex(9999);

You can set it’s value to big enough for make it show in top of other items.

Regards,

Ethan

Done , Thanks @Ethan

@Ethan one small isuue can you make that vector layer warp. that wrapdateLine property is not effecting . Please It will be helpful.

Also After updating to 10.3.0

After zooming out graticule is not appearing and below error is coming.

Hi Bibek,

Could you please provide us a simple sample to reproduce it? We think it should be a bug but our sample cannot reproduce it, as below is our sample, you can also modify it to help us reproduce that.

9016.zip (102.6 KB)

Regards,

Ethan

@Ethan ,What about wrapdateline ?

Hi Bibek,

The sample is based on a project for other user, you can just remove the code you think is not useful for reproduce the problem.

Regards,

Ethan

9016.zip (106.1 KB)
I have modified your example check it. While Zoom out it’s coming.

@Ethan , please modify that 9229.zip to make the vector layer wrapdateLine enable .

Hi Bibek,

Thanks for your sample, we had reproduced it, our developer will work for it.

We will update here if it get solved.

Regards,

Ethan

Hi Bibek,

Please download the https://www.nuget.org/packages/ThinkGeo.MapSuite/10.3.1 when it can be downloaded in one or two days.

Regards,

Ethan