It is currently Thu Oct 17, 2019 11:29 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: Geolocation via WebGadget
PostPosted: Thu Oct 06, 2016 9:57 am 
Offline
User
User

Joined: Fri Mar 29, 2013 4:55 pm
Posts: 98
Location: Netherland
Hi JHPJHP,

Using a modified version of the quick method from the first post, directions can be returned in either an XML or JSON format:
Code:
InitNetwork()
Debug PeekS(ReceiveHTTPMemory("http://maps.google.com/maps/api/directions/xml?origin=Toronto&destination=Mount+Rushmore"), -1, #PB_UTF8)

Code:
InitNetwork()

Dim output.s(0) ;this will be resized later

Procedure ExplodeStringArray(Array A.s(1), S.s, Delimeter.s)
  Protected Count.i, I.i
  Count.i = CountString(S.s, Delimeter.s) + 1
 
  ;Debug Str(count) + " substrings found"
  Dim A.s(Count.i)
  For I.i = 1 To Count.i
    A.s(I.i - 1) = StringField(S.s, I.i, Delimeter.s)
  Next
  ProcedureReturn Count.i ;Return count of substrings
EndProcedure

Text.s = PeekS(ReceiveHTTPMemory("http://maps.google.com/maps/api/directions/xml?origin=oslo&destination=gibraltar&&language=en"), -1, #PB_UTF8)
(language=en --> "en" = own language)

ExplodeStringArray(Output(), Text.s, #LF$)

Debug "Travel directions" + ":"
Debug "=================== "

Teller.i = 1
For I.i = 0 To ArraySize(Output())
  If FindString(Output(I.i), "<html_instructions>", 1) > 0
    Output(I.i) = RemoveString(Output(I.i), "<html_instructions>")
    Output(I.i) = RemoveString(Output(I.i), "</html_instructions>")
    Output(I.i) = RemoveString(Output(I.i), "    ")
    Output(I.i) = RemoveString(Output(I.i), ";b&gt;")
    Output(I.i) = RemoveString(Output(I.i), "&lt")
    Output(I.i) = RemoveString(Output(I.i), ";/b&gt;")
    Output(I.i) = RemoveString(Output(I.i), ";/div&gt;")
    Output(I.i) = RemoveString(Output(I.i), ";div style=&quot;font size:0.9em&quot;&gt;")
    Output(I.i) = RemoveString(Output(I.i), ";div style=&quot;font-size:0.9em&quot;&gt;")
   
    Debug RSet(Str(Teller.i), 3, "0") + " -  " + Output(I.i)
    Teller.i + 1
  EndIf
Next I.i

Debug ""
Debug "End travel directions" + ":"
Debug "========================="


Little_man


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation via WebGadget
PostPosted: Sat Oct 15, 2016 1:45 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Hi Little_man,

That's very useful script, well done.

------------------------------------------------------------

Updated:
- added 1 example
-- Geolocation_Side_by_Side.pb / Geolocation_Side_by_Side_OSX.pb (geolocation_side_by_side.pbi)
-- display a map location beside the Street View of the same location
-- drag the golden emoji on the map side to a new location
-- click the size icon on the Street View side to toggle full-screen

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Thu May 30, 2019 4:58 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation via WebGadget
PostPosted: Sat Oct 15, 2016 2:05 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
this is a very cool thread! and i dont want to take away from what its main ability is, but I cant help but wonder -- the webgadget is getting the geolocation seemingly from the OS somewhere, so im thinking it would be better in at least some cases to also just directly get that data from the OS rather than go through the behemoth webgadget? :) I dont know where the data is coming from though but it's not like the web browser ever asks for it so surely its just existing OS data, along the lines of locale perhaps?

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation via WebGadget
PostPosted: Sat Oct 15, 2016 2:13 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Hi Keya,

The information is being requested from the Google Maps service...

See the first post [ Quick Method ] for script on how to request Geolocation data directly without using the WebGadget.

Here Little_man posted script to parse data using the Quick Method.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Sun May 26, 2019 4:12 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated:
- added an API Key (max 25000 requests per day)

It seems that Google is now making the key mandatory, so I've added one for testing purposes.

If you are using this method for more then just demoing the code, please get your own key, their free up to 25000 requests per day.
- https://developers.google.com/maps/documentation/javascript/usage

-----------------------------------------------------------------------

Updated:
- added a Linux version to the first post (tested in Ubuntu 17.04 :: 64 bit)
- applied some minor bug fixes to all packages

NB*: If you haven't already done so, you will need to install the Linux packages located in Setup/install_files.sh.

-----------------------------------------------------------------------

It has been reported that "Google has completely switched off the API-Key free version of their geocoding"...

While an API key is required, it comes with $200 in free credit per month; see the following: Google Cloud.

To test this I recently removed my billing account from the Google project assigned with the Google Maps API key. When the program was executed it reported that the query limit had been reached.

I then created a new billing account assign to the above mentioned Google project. When the program was executed it worked without error.

NB*: When setting up the billing account it states that no charges will be applied if the credit limit is reached until manually authorized.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Thu May 30, 2019 4:56 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Windows only):
- image sizes configured to use the built-in PureBasic DPI compiler option

--------------------------------------------------------

I thought I had all the DPI issues worked out, but further testing revealed numerous problems.

Tested Scale: 100%, 125%, 150%, 175%

Instead of reposting all the updated applications, I will just list them here:
- Geolocation: Google Maps
- Barcode Generator
- Deform Image: MLS
- LSB File Embedding

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jun 03, 2019 10:37 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Sat Jun 01, 2019 5:29 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Windows only):
- added full screen view; pressing the Google Maps full screen icon will now trigger a PureBasic event

Full Screen View
Applied some of the same techniques developed for HTML5 YouTube Player and HTML5 MP4 Player.

---------------------------------------------------------------

Updated (Windows only):
- added a splash window
- added a control window; full screen view
- enhanced full screen view

Before this version the examples were designed as templates to help others embed Google Maps into an application. With the latest updates the examples became more relevant as individual tools.

NB*: Most of the code has been restructured for improved performance and usability.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jun 03, 2019 10:36 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Sun Jun 02, 2019 7:32 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Windows only):
- added interactive markers; dragging a Google Map marker will now trigger a PureBasic event

Interactive Markers
Geolocation_Directions.pb includes two draggable markers, Geolocation_Side_by_Side.pb includes a draggable pegman.

Reference Material: https://developers.google.com/maps/documentation/javascript/reference/?csw=1#DirectionsRoute

------------------------------------------------------------

Updated (Window only):
- squashed some bugs
- better transitions
- some code improvements
- various enhancements

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Tue Jun 18, 2019 6:23 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Mon Jun 03, 2019 12:25 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Window only):
- saving map types between views
- renamed events to better match JS names
- cleaned up JS code some-what
- added a couple improvements

Map Types
Map types are now remembered between full screen and normal view.

Google wrote:
The following map types are available in the Maps JavaScript API:
roadmap :: displays the default road map view. This is the default map type.
satellite :: displays Google Earth satellite images.
hybrid :: displays a mixture of normal and satellite views.
terrain :: displays a physical map based on terrain information.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jun 03, 2019 10:36 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Mon Jun 03, 2019 6:03 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Window only):
- capturing zoom events
- capturing heading & pitch events
- squashed a bug
- optimized some of the JS code

Zoom Events
Zoom events are now passed from JS to PureBasic with the exception of Geolocation_IP_Address.pb.
Panorama zoom events are now supported in the example Geolocation_Side_by_Side.pb.

Heading & Pitch Events
Panorama heading & pitch events are now supported in the example Geolocation_Side_by_Side.pb.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Tue Jun 18, 2019 6:24 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Tue Jun 04, 2019 9:44 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Window only):
- added a new option to Geolocation_Directions.pb, Geolocation_Two_Points.pb
- improved event and error handling
- squashed a small bug
- some minor code improvements

Geolocation_Directions.pb
The "fit bounds" function is built-in to this type of map; unchecking Auto Zoom option will override this feature.

Geolocation_Two_Points.pb
Added the "fit bounds" function; unchecking Auto Zoom option will override this feature.

NB*: The next update will include a look-up database of previous searches.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jun 10, 2019 5:34 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Fri Jun 07, 2019 1:39 pm 
Offline
User
User

Joined: Fri Mar 29, 2013 4:55 pm
Posts: 98
Location: Netherland
JHPJHP,

;-----------------------------------------------------------------------------------------------------------------------------------------------------
Gives an error on your website;

Forbidden

You don't have permission to access / on this server.


Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
;-----------------------------------------------------------------------------------------------------------------------------------------------------

Little_man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Fri Jun 07, 2019 9:13 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Hi Little_man,

I have temporarily made changes to the websites main .htaccess file; currently only direct access is available.

--------------------------------------------

Updated (Windows):
- all four examples have received numerous improvements

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Geolocation: Google Maps
PostPosted: Fri Jun 14, 2019 4:14 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Windows):
- added Location List of previously visited sites; some items can be modified directly
-- right-mouse click item to toggle TRUE / FALSE
-- right-mouse click item to open context menu
-- press delete key to delete record
-- click column to change sort order
-- double-click record to open location

Geolocation_Directions.pb
- dragging A / B marker to a new location will create a new record (map object)
- item is updated when Travel Mode is changed (PB gadget)
- item is updated when Hide Panel is changed (PB gadget)
- item is updated when Auto Zoom is changed (PB gadget)
- item is updated when Map Type is changed (map object)
- * item is updated when Full Screen is toggled (map object)
- item is updated when Zoom Level is changed (map object)

Geolocation_IP_Address.pb
- item is updated when Zoom Level is changed (PB gadget)
- item is updated when Map Type is changed (map object)
- * item is updated when Full Screen is toggled (map object)

Geolocation_Side_by_Side.pb
- dragging pegman to a new location will create a new record (map object)
- item is updated when Map Type is changed (map object)
- * item is updated when Full Screen is toggled (map / panorama object)
- item is updated when Split Screen is toggled (map / panorama object)
- item is updated when Zoom Level is changed (map / panorama object)
- item is updated when Heading is changed (panorama object)
- item is updated when Pitch is changed (panorama object)

Geolocation_Two_Points.pb
- item is updated when Auto Zoom is changed (PB gadget)
- item is updated when Map Type is changed (map object)
- * item is updated when Full Screen is toggled (map object)
- item is updated when Zoom Level is changed (map object)

When the program is first opened the location will default to the first saved record.
* Press the Escape key to exit full screen without updating the full screen item.
Double click the Control window title bar for semi-transparent, single click to exit transparency.
The Control window close button will exit the program.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Geolocation: Google Maps
PostPosted: Mon Jun 17, 2019 5:49 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1585
Updated (Windows):
- Geolocation_Directions.pb
-- added styles\geolocation_directions.json
- renamed Geolocation_Side_by_Side.pb to Geolocation_Split_View.pb
- Geolocation_Split_View.pb
-- added includes\geolocation_autocomplete.pbi
- small enhancements and bug fixes to all examples

Geolocation_Directions.pb
Styled MapType added; JSON file created using https://mapstyle.withgoogle.com/.

Geolocation_Split_View.pb
Replaced a PureBasic StringGadget with a Google Maps Places Autocomplete window, designed to look like the original StringGadget.
Due to the design layout of the main window, the Autocomplete window is styled with #WS_EX_LAYERED (steals focus from main window).
With a different design choice the Autocomplete window could have been styled with #WS_CHILD & ~(#WS_POPUP).
Alternately, a WebGadget could have been placed directly on the main window, as was done with Barcode Generator.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Fri Jun 21, 2019 2:50 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye