How to read data from the map

0 Answers 51 Views
Map
Pierpaolo
Top achievements
Rank 1
Pierpaolo asked on 08 Nov 2023, 03:15 PM

I've implemented a map that draws features from a geoJSON and I colour the features based on the values read from a separate JSON file, inside

shapeCreated


For testing purpouse, I need to read the features from the map to check that the correct colours have been assigned to each of the features.

How can I read data back from the map? Mind you, from the map, not from the geoJSON, i.e.: after the style of shapeCreated has been assigned

Nikolay
Telerik team
commented on 13 Nov 2023, 12:46 PM

Hi Pierpaolo,

You can access the data items for the features in the shapeFeatureCreated event handler:

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/map/events/shapefeaturecreated

Here is the full list of the data you can access inside the event: 

In case this is not what you are looking for could you pelase share more information so I can have a better understanding?

Regards,

Nikolay

Pierpaolo
Top achievements
Rank 1
commented on 13 Nov 2023, 05:59 PM

What I need is a way to iterate the shapes rendered on the map and read the fill colour, to compare it with the entity data:

e.g.: let's say that Italy should be coloured white, I need to check that its shape on the map has beed rendered in white colour.

The reason being that I randomly found out that the code of one shape (inside the geojson file) was different from the code for the same country in the data represented and, consequently, its colour on the map was wrong.

Nikolay
Telerik team
commented on 16 Nov 2023, 02:33 PM

Hi Pierpaolo,

Is it possible to share a runnable Dojo demo where the problem is replicated so I can investigate further?

Regards,

Nikolay

Pierpaolo
Top achievements
Rank 1
commented on 16 Nov 2023, 04:38 PM

Hi Nikolay, 

I don't have a dojo demo that I could share but any choropleth map would do. 

I need code to read the colour of a shape from the rendered map.

Pierpaolo
Top achievements
Rank 1
commented on 16 Nov 2023, 06:08 PM

I found this old dojo from an old ticket of mine. Although it is currently not working, I see that your colleague suggested the approach to store the rendered shapes inside an object within the onShapeCreated event and parse the object to check the colours. 

Would that still be the recommended approach or is there a functionality that renders storing the shapes inside a dedicated object unnecessary?
Nikolay
Telerik team
commented on 21 Nov 2023, 10:50 AM

Hi Pierpaolo,

This approach is still valid and I recommend sticking to it. I have updated Dojo to the latest Kendo UI version:

https://dojo.telerik.com/EvEromob

Regards,

Nikolay

Pierpaolo
Top achievements
Rank 1
commented on 21 Nov 2023, 10:58 AM

Thanks for updating the dojo for me. So did I get this right? Storing the shapes within the onShapeCreated is the onky way to access them after the page has been rendered?
Nikolay
Telerik team
commented on 24 Nov 2023, 06:41 AM

Hi Pierpaolo,

Yes, that is correct. Store the shapes within the onShapeCreated to access them after the page has been rendered.

Regards,

Nikolay

Pierpaolo
Top achievements
Rank 1
commented on 24 Nov 2023, 07:56 AM

Thanks. I've been hoping in a direct access to the shapes, without using more objects, especially considering it's for testing purposes.

No answers yet. Maybe you can help?

Tags
Map
Asked by
Pierpaolo
Top achievements
Rank 1
Share this question
or