Feb 3, 2018 Replies: 8 Hi, This is a class for getting place name (name of building, plaza, mall, tower, etc.) from Google Places API. Place is identified using Place ID which can be retrieved for example in geocoding result from Google Geocoding API. I use this class in my app BS Where Am I . Perhaps anyone want to use this class. It uses HttpUtils2 and JSON libraries. It is a simple code, but it's just enough for my current need. You may use, modify, or distribute anyway you want. If would be great if you inform me for any enhancement. Cheers, Attachments TPlacesDetail.bas TPlacesDetail.bas 3.4 KB · Views: 438 Last edited: Feb 3, 2018 Click to expand...
Hi, This is a class for getting place name (name of building, plaza, mall, tower, etc.) from Google Places API. Place is identified using Place ID which can be retrieved for example in geocoding result from Google Geocoding API. I use this class in my app BS Where Am I . Perhaps anyone want to use this class. It uses HttpUtils2 and JSON libraries. It is a simple code, but it's just enough for my current need. You may use, modify, or distribute anyway you want. If would be great if you inform me for any enhancement. Cheers,
X Xenno Member Licensed User Feb 3, 2018 #2 Public Methods Initialize It is for initializing the object. Parent is caller module name. Note: API Key is required. Get it from Google Places API. Code: Copy Public Sub Initialize(prmParent As Object, prmEventName As String, prmAPIKey As String) getPlaceId Get current Place ID; available after calling GetPlaceNameFromId. Code: Copy Sub getPlaceId As String GetPlaceNameFromId Get place name based on a Place ID. The result event are [eventname]_OnSuccess and [eventname]_OnError. Parent module needs to declare these routines. Code: Copy Sub GetPlaceNameFromId(prmPlaceId As String)
Public Methods Initialize It is for initializing the object. Parent is caller module name. Note: API Key is required. Get it from Google Places API. Code: Copy Public Sub Initialize(prmParent As Object, prmEventName As String, prmAPIKey As String) getPlaceId Get current Place ID; available after calling GetPlaceNameFromId. Code: Copy Sub getPlaceId As String GetPlaceNameFromId Get place name based on a Place ID. The result event are [eventname]_OnSuccess and [eventname]_OnError. Parent module needs to declare these routines. Code: Copy Sub GetPlaceNameFromId(prmPlaceId As String)
X Xenno Member Licensed User Feb 3, 2018 #3 Short Example Preparing the object as usual. Code: Copy Dim mPlaces As TPlacesDetail ... mPlaces.Initialize(Me, "mPlaces", kPlaceAPIKey) Replace kPlaceAPIKey with your own key. Write two subroutines for events. Code: Copy Sub mPlaces_OnSuccess(prmPlaceName As String) Log("Place name: " & prmPlaceName) End Sub Sub mPlaces_OnError(prmMsg As String) Log(prmMsg) End Sub Get the Place ID from geocoding event then call GetPlaceNameFromId of mPlaces object. Code: Copy Dim results As List Dim oneResult As Map results = json.Get("results") If (results.Size > 0) Then oneResult = results.Get(0) .... placeId = oneResult.Get("place_id") mPlaces.GetPlaceNameFromId(mPlaceId) Else Log("Could not resolve address") End If
Short Example Preparing the object as usual. Code: Copy Dim mPlaces As TPlacesDetail ... mPlaces.Initialize(Me, "mPlaces", kPlaceAPIKey) Replace kPlaceAPIKey with your own key. Write two subroutines for events. Code: Copy Sub mPlaces_OnSuccess(prmPlaceName As String) Log("Place name: " & prmPlaceName) End Sub Sub mPlaces_OnError(prmMsg As String) Log(prmMsg) End Sub Get the Place ID from geocoding event then call GetPlaceNameFromId of mPlaces object. Code: Copy Dim results As List Dim oneResult As Map results = json.Get("results") If (results.Size > 0) Then oneResult = results.Get(0) .... placeId = oneResult.Get("place_id") mPlaces.GetPlaceNameFromId(mPlaceId) Else Log("Could not resolve address") End If
LucaMs Expert Licensed User Longtime User Feb 3, 2018 #4 1) I've never "played" with Google maps but... why not display them too? 2) from your app: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am
1) I've never "played" with Google maps but... why not display them too? 2) from your app: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am
X Xenno Member Licensed User Feb 3, 2018 #5 LucaMs said: 1) I've never "played" with Google maps but... why not display them too? 2) from your app: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am Click to expand... Hello, LucaMs Displaying map requires loading time and processing. BS Where Am I is intended to be quick and simple. I'm sorry that the app does not work well for you. I use it daily; getting know my position while at the same time testing the app. The widget is my handy tool to quickly get the information. Thank you for your comment and input. I will look at my code. Anyway, this thread is focused on TPlacesDetail. So, please understand I can't discuss further about BS Where Am I here. Cheers, Last edited: Feb 3, 2018
LucaMs said: 1) I've never "played" with Google maps but... why not display them too? 2) from your app: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am Click to expand... Hello, LucaMs Displaying map requires loading time and processing. BS Where Am I is intended to be quick and simple. I'm sorry that the app does not work well for you. I use it daily; getting know my position while at the same time testing the app. The widget is my handy tool to quickly get the information. Thank you for your comment and input. I will look at my code. Anyway, this thread is focused on TPlacesDetail. So, please understand I can't discuss further about BS Where Am I here. Cheers,
LucaMs Expert Licensed User Longtime User Feb 3, 2018 #6 LucaMs said: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am Click to expand... Xenno said: I'm sorry that the app does not work well for you. Click to expand... I wrote "I'm lost", in quotes and added , because "I am lost" but not geographically. It was a joke
LucaMs said: "Are you lost?". Well, your app does not work well, because "I'm lost" but it is not able to say me where I am Click to expand... Xenno said: I'm sorry that the app does not work well for you. Click to expand... I wrote "I'm lost", in quotes and added , because "I am lost" but not geographically. It was a joke
Almora Well-Known Member Licensed User Longtime User Feb 3, 2018 #7 If GPS is active it works very well.
X Xenno Member Licensed User Feb 3, 2018 #8 LucaMs said: I wrote "I'm lost", in quotes and added , because "I am lost" but not geographically. It was a joke Click to expand... Oh, okay.... Hahaha.... Yes, yes.. I'm sorry. Forgive my English. I am from Indonesia. I didn't know it was a joke. Last edited: Feb 3, 2018
LucaMs said: I wrote "I'm lost", in quotes and added , because "I am lost" but not geographically. It was a joke Click to expand... Oh, okay.... Hahaha.... Yes, yes.. I'm sorry. Forgive my English. I am from Indonesia. I didn't know it was a joke.
X Xenno Member Licensed User Feb 3, 2018 #9 Almora said: If GPS is active it works very well. Click to expand... Glad to know, Almora. Thanks,