Map in angular

20 views
Skip to first unread message

Harsha Priya G

unread,
Mar 19, 2021, 10:39:57 AM3/19/21
to ang...@googlegroups.com
I tried {{data.not_usstate}} in  app.component.html i got this api populated in my window.....
{
    "not_usstates": "{\"type\": \"FeatureCollection\", \"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"EPSG:4326\"}}, \"features\": [{\"type\": \"Feature\", \"properties\": {\"state_name\": \"NOT_US\"}, \"geometry\": {\"type\": \"MultiPolygon\", \"coordinates\": [[[[78.21071029010544, 8.83844406898327], [78.21113528186422, 8.83840734505093], [78.21148633227308, 8.838444149506403], [78.2117634958757, 8.838389044083215], [78.21194827044498, 8.838242027066373], [78.21211458199711, 8.838076679629625],6.73816885062907, 10.895398099601442], [76.73784285270953, 10.895681012516938], [76.73754431365079, 10.895883584792713], [76.73703069671411, 10.896070928801128], [76.73658112372917, 10.896244718005606], [76.7362271271908, 10.896550780381627], [76.73553443655618, 10.89688187093712], [76.73509914247597, 10.897029026652302], [76.73458605334086, 10.897148539311432], [76.73379783455105, 10.897307707048014], [76.73300559263419, 10.897416527739484], [76.73292321655417, 10.897434069481102], [76.73250161660742, 10.897499775125532], [76.73198449475932, 10.897555921247585], [76.7316773225831, 10.897654419563235], [76.73157154093614, 10.897766450003633], [76.73145201468384, 10.897888091615984], [76.73134105204282, 10.898000652570868], [76.73120780248476, 10.898172068922742], .........[78.94975602886872, 13.079979781851133], ]]]}}]}"
}
How to display the coordinates alone in angular ? and display the same in open layers map??

khushbu poddar

unread,
Mar 22, 2021, 6:07:17 AM3/22/21
to ang...@googlegroups.com, harshapri...@gmail.com
HI,

Use JSON.parse.

Copy this value in say variable response.

let requiredValue = JSON.parse(response.not_usstates);
console.log(requiredValue.features[0].geometry.coordinates)
// your required coordinates

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CAE6O3onZ9OkLirOwi-tDE__%3DxDyVyNY33ETao1n%2B_Thc4CzU3A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages