Geolocation: Google Maps

Developed or developing a new product in PureBasic? Tell the world about it.
Little_man
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Re: Geolocation: Google Maps

Post by Little_man »

JHPJHP,

A location with a ' gives an error (sample: 't hofke 1, Eindhoven)

Little_man
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Geolocation: Google Maps

Post by JHPJHP »

Hi Little_man,

Thank you for posting your results.
Little_man wrote:A location with a ' gives an error (sample: 't hofke 1, Eindhoven)
That issue should have been fixed a few versions back, including numerous minor improvements and bug fixes.

Just in case, I recompiled the latest Windows examples; direct download available from my website.
Last edited by JHPJHP on Fri Jun 21, 2019 5:27 pm, edited 1 time in total.
Little_man
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Re: Geolocation: Google Maps

Post by Little_man »

JHPJHP,

Start location: t Hofke 1, eindhoven, programma gives location: 't Hofke 30, 5641 AH Eindhoven, Nederland (this is correct zipcode).
End location: eindhoven, Nederland, programma gives: Eindhoven, Nederland.

Pushing the green arrow, information will be saved in database.
Then double click in the database that shows the SplashWindow and after a while I get a black window

Little_man
User avatar
Kiffi
Addict
Addict
Posts: 1353
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Geolocation: Google Maps

Post by Kiffi »

Little_man wrote:Pushing the green arrow, information will be saved in database.
This looks like a typical insert problem in connection with string concatenation.

myValue = "'t Hofke"

"INSERT INTO myTable (myColumn) VALUES ('" + myValue + "')"

Solution: Try doubling the apostrophe before the insert.

myValue = "'t Hofke"
myValue = ReplaceString(myValue, "'", "''")

(I hope you can recognize the fat red apostrophes.)

Greetings ... Peter
Hygge
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Hi Little_man

The problem stems from Google Maps handling of some address' through some of its services.

Translating the address to latitude / longitude using an alternate Google Maps service seems to have fixed the problem.
- geolocation_autocomplete.pbi and geolocation_directions.pbi have been updated

Please test the updated examples to confirm that the problem has been resolved.

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

Hi Kiffi,

Thank you for your post.
Kiffi wrote:Solution: Try doubling the apostrophe before the insert.
Doubling a single-quote for SQL statements has already been written into the code; see Procedure DatabaseSetRow().
Last edited by JHPJHP on Mon Jun 24, 2019 3:06 am, edited 2 times in total.
Little_man
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Re: Geolocation: Google Maps

Post by Little_man »

JHPJHP

Problem has been resolved.

Little_man
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows):
- added a language window
- added map styles
- couple minor improvements

Language Window
Selecting a language will close the window, reloading the current map in that language.
No database record is created until the current map is refreshed or a new map is retrieved.

Map Styles
Multiple JSON files can be associated to each example.
MapType name is taken from the JSON file name.
- text between string symbols (eg. \styles\geolocation_two_points$Retro$.json)

Map styles can be created from the following link: https://mapstyle.withgoogle.com/
Here is a site with over 1500 preconfigured map styles: https://snazzymaps.com/

NOTE
After upgrading to PureBasic 5.71 beta 2 LTS, the full screen Procedure needed modifying due to some aspect ratio issues.
Earlier versions of PureBasic may experience problems in full screen mode due to the recent changes (untested).
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows):
- couple minor improvements
- couple bug fixes

Minor Improvements
Geolocation_Directions.pb:
- modified the directions algorithm
- added the option to remove the markers (Location List)
- added the option to change the line color (Location List)
- Saving the map will temporarily hide the map controls
Geolocation_IP_Address.pb:
- added the option to change the circle color (Location List)
- Saving the map will temporarily hide the map controls
Geolocation_Split_View.pb:
- various changes to improve the user experience
- Saving the map will temporarily hide the map controls
Geolocation_Two_Points.pb:
- added the option to change the line color (Location List)
- Saving the map will temporarily hide the map controls
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Geolocation: Google Maps

Post by JHPJHP »

Updated:
- fixed Geolocation_IP_Address.pb

Geolocation_IP_Address.pb
There was a format change to the IP-API XML download.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated:
- improved various parts of the code
- renamed some include files

Most of the updates were to the example Geolocation_Split_View.pb.
- updated version renamed to Geolocation_Split_View_1.pb
- original version renamed to Geolocation_Split_View_2.pb

While the Autocomplete "window" in the old version drew focus away from the main window, in the new version it acts more like a PureBasic Gadget.

NB*: Only the Windows package was updated.
Last edited by JHPJHP on Mon Aug 09, 2021 1:28 am, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows package):
- some minor improvements
- squashed a couple bugs

Most changes were to the Split View examples.
Last edited by JHPJHP on Sun Mar 20, 2022 6:08 am, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows package):
- added Prediction option to Split View example
- removed second Split View example
- various other improvements

Google Prediction Service
Previously the use of the Google Prediction Service was not optional, but I noticed with some locations (i.e. The Great Pyramid) a street address was returned instead of the actual request. The user now has the option to use or not use the Google Prediction Service for improved results.
Last edited by JHPJHP on Fri Mar 17, 2023 10:41 pm, edited 2 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows only):
- added User Agent to bypass Google API warning
- control window (lock) transparency changed from double-click to right-click

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

Modified the User Agent
Fixing one problem seemed to have caused another... some Google Maps API stuff stopped working.
I thought I was being clever selecting a Chrome User Agent; using an Edge User Agent fixed the problem.

NB*: Google Translate Service was also updated for consistency.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated (Windows only):
- modified Geolocation_Two_Points.pb
- couple minor improvements

Geolocation_Two_Points.pb
Previous method for adding custom markers was depreciated, and the marker URL was no longer valid.
Last edited by JHPJHP on Fri Mar 17, 2023 10:41 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Geolocation: Google Maps

Post by JHPJHP »

Updated:
- modified User Agent for better compatibility

Weird Behavior
For the previous few weeks, I tested Geolocation: Google Maps, but they were not working, I assumed it had to do with Microsoft permanently disabling Internet Explorer 11 on February 14, 2023.

I tried again today and "lo and behold" things were working again, but I did notice a problem with map animations. After testing various User Agent's I settled on one that provided better support for not only Google Maps, but also my YouTube Player & Downloader, which has also been updated.

NB*: Free executables (x86/x64) were updated and can be downloaded from My PureBasic Stuff; see FREE STUFF.

Image Image
Image Image
Locked