WGoogleMap Search
Added by Alen Damadzic about 9 years ago
Is it possible to use WGoogleMap without knowing co-ordinates. For example, if a user enters his hometown as Paris, I'd like to display a map of Paris.
Can WGoogleMap be passed a string to lookup, or is there some other API I can use to lookup the co-ordiantes based on a town name for example.
Pardon my ignorance if the answer is blindingly obvious.
Thanks, Alen
Replies (3)
RE: WGoogleMap Search - Added by Derek Spenser about 9 years ago
Alen
I would look into a solution using Wt::Http::Client and Google's geocoding api which would return the coordinates in a json object that could be parsed with Wt::Json.
Here's some untested pseudocode:
// request geocode information through Google's geocoding api using Wt::Http::Client
// obtain response from Google through Wt::Http::Message
// create Json object from response
// create Wt::WGoogleMap::Coordinate from parsing json object
// instantiate Wt::WGoogleMap with Coordinates
Documentation for Google's geocoding api can be found here:
https://developers.google.com/maps/documentation/geocoding/
I don't know if that's the best way, but hope that helps.
RE: WGoogleMap Search - Added by Alen Damadzic about 9 years ago
Thanks for the feedback, the Geocoding API is pretty simple to use.
I am getting issues however when using Http::Client. Im getting a "broken pipe" error.
Any pointers on where this is coming from?
RE: WGoogleMap Search - Added by Derek Spenser about 9 years ago
Alen
Sounds like a network issue; maybe from boost asio? I'm not quite sure. I think a detailed error log or stacktrace would be needed to pin point the issue. I would recommend checking two things initially; 1. connection to the internet. 2. correct privileges for boost asio? Like I mentioned, I'm not sure...those are just two thoughts off the top of my head. Maybe someone else has more experience with that error.
-Derrek