Skip to main content
edited title
Link
Marc Pfister
  • 4.1k
  • 17
  • 11

Converting JSON responceresponse into a GeoJSON layer in my Leaflet map

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+profilekey=<API_KEY>&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{
   "shapePoints":[
      39.74012,
      -104.9849,
      39.7995,
      -105.7237,
      39.6404,
      -106.3736
   ],
   "elevationProfile":[
      {
         "distance":0,
         "height":1616
      },
      {
         "distance":63.5583,
         "height":3910
      },
      {
         "distance":121.9561,
         "height":2501
      }
   ],
   "info":{
      "copyright":{
         "text":"© 2018 MapQuest, Inc.",
         "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
         "imageAltText":"© 2018 MapQuest, Inc."
      },
      "statuscode":0,
      "messages":[

      ]
   }
}

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{
   "shapePoints":[
      39.74012,
      -104.9849,
      39.7995,
      -105.7237,
      39.6404,
      -106.3736
   ],
   "elevationProfile":[
      {
         "distance":0,
         "height":1616
      },
      {
         "distance":63.5583,
         "height":3910
      },
      {
         "distance":121.9561,
         "height":2501
      }
   ],
   "info":{
      "copyright":{
         "text":"© 2018 MapQuest, Inc.",
         "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
         "imageAltText":"© 2018 MapQuest, Inc."
      },
      "statuscode":0,
      "messages":[

      ]
   }
}

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=<API_KEY>&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{
   "shapePoints":[
      39.74012,
      -104.9849,
      39.7995,
      -105.7237,
      39.6404,
      -106.3736
   ],
   "elevationProfile":[
      {
         "distance":0,
         "height":1616
      },
      {
         "distance":63.5583,
         "height":3910
      },
      {
         "distance":121.9561,
         "height":2501
      }
   ],
   "info":{
      "copyright":{
         "text":"© 2018 MapQuest, Inc.",
         "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
         "imageAltText":"© 2018 MapQuest, Inc."
      },
      "statuscode":0,
      "messages":[

      ]
   }
}

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{ "shapePoints":[ 39.74012, -104.9849, 39.7995, -105.7237, 39.6404, -106.3736 ], "elevationProfile":[ { "distance":0, "height":1616 }, { "distance":63.5583, "height":3910 }, { "distance":121.9561, "height":2501 } ], "info":{ "copyright":{ "text":"© 2018 MapQuest, Inc.", "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif", "imageAltText":"© 2018 MapQuest, Inc." }, "statuscode":0, "messages":[

{
   "shapePoints":[
      39.74012,
      -104.9849,
      39.7995,
      -105.7237,
      39.6404,
      -106.3736
   ],
   "elevationProfile":[
      {
         "distance":0,
         "height":1616
      },
      {
         "distance":63.5583,
         "height":3910
      },
      {
         "distance":121.9561,
         "height":2501
      }
   ],
   "info":{
      "copyright":{
         "text":"© 2018 MapQuest, Inc.",
         "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
         "imageAltText":"© 2018 MapQuest, Inc."
      },
      "statuscode":0,
      "messages":[

      ]
   }
}

} }

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{ "shapePoints":[ 39.74012, -104.9849, 39.7995, -105.7237, 39.6404, -106.3736 ], "elevationProfile":[ { "distance":0, "height":1616 }, { "distance":63.5583, "height":3910 }, { "distance":121.9561, "height":2501 } ], "info":{ "copyright":{ "text":"© 2018 MapQuest, Inc.", "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif", "imageAltText":"© 2018 MapQuest, Inc." }, "statuscode":0, "messages":[

  ]

} }

I need to convert a JSON response from Mapquest elevation API into a GeoJSON layer in my Leaflet map.

var ele = $.getJSON('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+profile);

this is a sample of JSON reponse:

{
   "shapePoints":[
      39.74012,
      -104.9849,
      39.7995,
      -105.7237,
      39.6404,
      -106.3736
   ],
   "elevationProfile":[
      {
         "distance":0,
         "height":1616
      },
      {
         "distance":63.5583,
         "height":3910
      },
      {
         "distance":121.9561,
         "height":2501
      }
   ],
   "info":{
      "copyright":{
         "text":"© 2018 MapQuest, Inc.",
         "imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
         "imageAltText":"© 2018 MapQuest, Inc."
      },
      "statuscode":0,
      "messages":[

      ]
   }
}
Source Link
Eslam Farag
  • 109
  • 1
  • 13
Loading