react-google-maps icon indicating copy to clipboard operation
react-google-maps copied to clipboard

Elevation Service

Open tedabbott opened this issue 10 years ago • 2 comments

Your component works great in our isomorphic, universal application, and I have one additional requirement that I was hoping your component could help me with. We need to plot elevation data on a line chart to determine line-of-site from start to end lat/lng positions. Would it be possible for you to add the ElevationService (similar in the manner for which you have added the DirectionsService) so that it will return the elevation data? I'm currently using a server side JSON file to mock elevation data because I'm having some issue with the google maps API to play nicely with node.js; just starting to go down the path of adding the API manually, but the following example would be all I need from the output of such an addition to your project and would save a ton of time researching:

/* 1st two plot points of an elevation service request) */ { "results": [ { "elevation": 313.8795471191406, "location": { "lat": 33.753, "lng": -84.386 }, "resolution": 9.543951988220215 }, { "elevation": 314.2392272949219, "location": { "lat": 33.75327661697548, "lng": -84.38545763308723 }, "resolution": 9.543951988220215 } ], "status": "OK" }

tedabbott avatar Jan 21 '16 22:01 tedabbott

I moved the request to ElevationService over to a server that I could control the access-control-allow-origin header to the Google Maps API. That server is a trusted end-point to my node.js / React, Isomorphic app, and so I pass the request from node.js to the trusted server, and that server makes the request to the Google Maps API for me and returns the JSON Elevation data back to the React app. A bit of a long work-around, but the trusted server also happens to be a partial API to the full application, so it works... (And I didn't just go out and stand up a full server just to make GMAPI requests from ... o.O)

It would be neat if r-g-m wrapped ElevationService so that I could access it as part of the ScriptjsLoader, but at this time, I probably won't be coming back to r-g-m to get that data since I have a permanent, working solution, so I'm closing w/ functions as designed.

thanks

tedabbott avatar Feb 03 '16 23:02 tedabbott

Sorry I don't familiar with ElevationService. Feel free to open up a PR if you like to contribute a wrapper component.

tomchentw avatar Feb 20 '16 05:02 tomchentw