Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Google places API using Http_get().

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Google places API using Http_get().

    I am trying to get "THINGS" from google places API. My problem is when I am in a large town or not in a town. I need to pass the Lat Lng.

    I am thinking Http_get(). The URL I am using is of this format with a key at the end. ( License_key)


    https://maps.googleapis.com/maps/api...tion=51.373810, 0.452608&radius=10000&types=bar&key=License_key



    Steve Wood mentioned this example because the site is Https

    http_get("https://www.sqst.com","",443,0,.f.,.f.)

    Once I get the object I can use a list control to display it.

    My question is can someone explain in very simple steps what I need to do. I need to build the URL in xbasic as I would rather keep the key hidden.
    I would like to have {dialog.object}._places returned.


    JSON Places.png


    Sorry David I am using 12.4.3.1 build 3962

    #2
    Re: Google places API using Http_get().

    The list control can return both the lat,lng on the map without your process. Video UXL_V12_58 as a starting point.
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

    Comment


      #3
      Re: Google places API using Http_get().

      Not sure I understand what you're wanting to do... even though you've said. You want to create the URL in XBasic? You want to build a string for the URL? Do you want to use http_get... or not? You also write that you want the returned JSON going into a namespace variable. So... what's the issue?

      Comment


        #4
        Re: Google places API using Http_get().

        Sorry

        I am trying to use Google places.

        https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=51.373810, 0.452608&radius=10000&types=bar&key=License_key

        https://maps.googleapis.com/maps/api/place/nearbysearch/json? I am asking for Json back.

        location=51.373810, 0.452608 I have found my location from the phone.

        &radius=10000 within a radius of 10,000 mtrs.

        &types=bar I want all bars returned.

        As you can see from my picture (above) Google returns a complex JSON object that Alpha allows me to format. If I put this object in a list I can display it on the phone.
        After I have all of the bars, car parks, atm's in the list I can show people where they are on a map.

        Google also returns the place Id.
        Google has code for this that works in small towns but in larger towns, it gives a very focused data set. So with this URL, I can tell Google my position. Obviously the URL needs to be dynamic.

        Location changes
        Types changes (atm, bars etc)
        radius will be smaller in a city centre than on a motorway.

        I have no idea how to furnish Google with my URL and then how to get the returned JSON into a JavaScript variable.

        Comment


          #5
          Re: Google places API using Http_get().

          re: &radius=10000 within a radius of 10,000 mtrs etc. This is a standard setting in the Lists search.... I think your are just taking a difficult and unnecessary path.
          Insanity: doing the same thing over and over again and expecting different results.
          Albert Einstein, (attributed)
          US (German-born) physicist (1879 - 1955)

          Comment


            #6
            Re: Google places API using Http_get().

            Does Alpha support places? The places API is a separate API.

            Loading the library

            The Places service is a self-contained library, separate from the main Maps JavaScript API code. To use the functionality contained within this library, you must first load it using the libraries parameter in the Maps API bootstrap URL:
            I have seen no reference to support for anything but the maps API.

            Comment


              #7
              Re: Google places API using Http_get().

              I'm a little confused... but... I believe this is what you're looking for. Ajax Callback, with Location information, to call Google Places and return that data to a List.

              Ajax Callbacks include the option to pass through location information into e.__locationLatitude and e.__locationLongitude... so that's all good.

              Use that location data in the Google Places call. Returned results include JSON in a .body property.

              Set up a List Control for data coming from a Javascript function. The Javacsript function will process the Places JSON picking out what you want to show.

              The attached example doesn't go into more detail than just a straight List... however... this could get interesting because the Places JSON is a hierarchy and the List control can handle that very nicely.

              There is a button on the attached example (remember to put your Google Key into the XBasic function) which calls the XBasic function getPlaces... passing in location info...

              Code:
              function getPlaces as c (e as p)
              	
              
              debug(1)
              
              dim url as c
              
              dim latLng as c
              if variable_exists("e.__locationLatitude") then
              	latLng = e.__locationLatitude + "," + e.__locationLongitude	
              else
              	latLng = "51.373810,0.452608"
              end if
              
              url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + latLng + "&radius=10000&types=bar&key=your key here"	
              
              dim result as p
              result = http_get(url,"",443,0,.f.,.f.)
              
              getPlaces = "{dialog.Object}.__places=" + result.body + ";{dialog.object}.refreshListData('listPlaces');"
              
              	
              end function
              Return the Places JSON in a namespace variable and refresh the List control.

              The List control data source is a Javascript function...

              Code:
              function showPlaces(){
              
              	if({dialog.Object}.__places==undefined){
              		return '';
              	}else{
              		var listData = [];
              		for(i=0;i<{dialog.Object}.__places.results.length;i++){
              			var listRow = {};
              			listRow.name = {dialog.Object}.__places.results[i].name;
              			listRow.lat = {dialog.Object}.__places.results[i].geometry.location.lat;
              			listRow.lng = {dialog.Object}.__places.results[i].geometry.location.lng;
              			listData.push(listRow);
              		}
              		return listData;
              	}
              
              }
              This takes the Places data... picks out the Name, Lat, Lng... builds an array of objects and returns that to the List... resulting in...

              Google_Places_List.PNG

              ux_Google_Maps_Places_API_Test.a5wcmp
              Last edited by Davidk; 02-23-2017, 10:26 AM.

              Comment


                #8
                Re: Google places API using Http_get().

                Thanks David,

                I will try it and report back.

                Comment


                  #9
                  Re: Google places API using Http_get().

                  Thanks David

                  It works, there was a small typo.

                  dim url as
                  Should read

                  dim url as c

                  debug(1) found that.

                  My first try I was so excited I forgot my license key.


                  So edit the dim url statement and enter your license key and you have a working places search.

                  Permissible types are documented here

                  https://developers.google.com/places...upported_types

                  Comment


                    #10
                    Re: Google places API using Http_get().

                    David has given you a great jump start on this, just follow his advice. You need to use the latest build if you want to use markers in the List, you can get an idea of the kind of things possible in this quick Video.

                    https://www.screencast.com/t/X0KGbUhi
                    Insanity: doing the same thing over and over again and expecting different results.
                    Albert Einstein, (attributed)
                    US (German-born) physicist (1879 - 1955)

                    Comment


                      #11
                      Re: Google places API using Http_get().

                      Thanks Pete,

                      I will post back when I have something interesting.

                      I want to use English in a dropdown so I need to translate the American types into readable English, but Alpha lets me do that.
                      I also want to change the radius of the search and then finally from the places Id display the google map info available.

                      Places Id.png

                      If you look carefully you will see under the icon Google is telling me I am 37 minutes away.

                      My users will be able to navigate to booking.com etc for a price.

                      Point of interest I was living in Brighton when the IRA bombed the Grand in an attempt to kill Maggie T.

                      Comment


                        #12
                        Re: Google places API using Http_get().

                        Don't forget if you use controls like the slider to select distance (or zoom) you need to return a number value the the map EG. var range = number(distance) - you get the idea.
                        Go for it mate!
                        Insanity: doing the same thing over and over again and expecting different results.
                        Albert Einstein, (attributed)
                        US (German-born) physicist (1879 - 1955)

                        Comment


                          #13
                          Re: Google places API using Http_get().

                          Thanks Michael, that's fixed in the post... I wrecked it in my posting cleanup.

                          Comment


                            #14
                            Re: Google places API using Http_get().

                            If my code was that problem free I could retire.

                            Just got a code sample in the form

                            function initialize() {

                            var map = new google.maps.Map(document.getElementById('map'), {
                            center: new google.maps.LatLng(-33.8665433, 151.1956316),
                            zoom: 15
                            });

                            var request = {
                            placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
                            };

                            var infowindow = new google.maps.InfoWindow();
                            var service = new google.maps.places.PlacesService(map);

                            service.getDetails(request, function (place, status) {

                            if (status == google.maps.places.PlacesServiceStatus.OK) {

                            var marker = new google.maps.Marker({
                            map: map,
                            position: place.geometry.location
                            });

                            google.maps.event.addListener(marker, 'click', function () {
                            infowindow.setContent(place.name);
                            infowindow.open(map, this);
                            });
                            }
                            });
                            };




                            Added to your code to get

                            var listRow = {};
                            listRow.name = {dialog.Object}.__places.results[i].name;
                            listRow.vicinity = {dialog.Object}.__places.results[i].vicinity;
                            listRow.place = {dialog.Object}.__places.results[i].place_id;
                            listRow.lat = {dialog.Object}.__places.results[i].geometry.location.lat;
                            listRow.lng = {dialog.Object}.__places.results[i].geometry.location.lng;
                            listData.push(listRow);

                            Now I have the postal address and the Place_Id with the place Id I can help clients find hotel prices with out learning a host of Hotel API's

                            Comment


                              #15
                              Re: Google places API using Http_get().

                              I have found the reference in David's code.

                              With this, I have got the place details I wanted.

                              This is Selwyn's component modified


                              ajaxcallback_crossdomain.a5wcmp

                              At the moment I am struggling with a cross domain callback

                              var listData = [];
                              for(i=0;i<{dialog.Object}.__places.results.length;i++){
                              var listRow = {};
                              listRow.name = {dialog.Object}.__places.results[i].name;
                              listRow.vicinity = {dialog.Object}.__places.results[i].vicinity;
                              listRow.place = {dialog.Object}.__places.results[i].place_id;
                              listRow.lat = {dialog.Object}.__places.results[i].geometry.location.lat;
                              listRow.lng = {dialog.Object}.__places.results[i].geometry.location.lng;
                              listRow.reference = {dialog.Object}.__places.results[i].reference;

                              listData.push(listRow);
                              }
                              return listData;
                              Note reference comes from here.

                              So this saves me going through the complexity of Place_Id

                              Comment

                              Working...
                              X