Android Question I Need Conversion of GoogleMap with marker from SQLite to PHP_MYSQL Version

omo

Active Member
Licensed User
Longtime User
Please, help me!
The attached file below populates markers from sqlite database, i don't have issues with using sqlite with google map and handling other semi-advanced issues after wonderful people like Erel, Don Manfred, Klaus, Mashiane (comprehensive php/mysql tutorial) and entire forum members had resolved my issues relating to google map in one way or the other in the past (God bless you all!). Now, what i need is to convert the code below (or anybody can give me another sample code) that populates custom markers on google map from mysql database using only php and b4a. I have tried several times to convert with no success, i don't have issues with handling CRUD operations in php/mysql, but showing custom markers have been giving me sleepless night since many days now.
 

Attachments

  • googlemap.zip
    20.3 KB · Views: 165

RVP

Active Member
Licensed User
Longtime User
Querying


from a database results in a mysql-error. This is the sql query your php is generating.
the answer to your action mapfrag is always empty as of the mysql-Error.


Your where clause needs to use the same calculation you are doing in th body for distance
 
Upvote 0

RVP

Active Member
Licensed User
Longtime User
B4X:
Querying
SELECT userfname, usersurname, usersex, userpic, userlongitude, userlatitude, (46.95 - userlatitude) * (46.95 - userlatitude) * 12364.311711488797 + (7.44 - userlongitude) * (7.44 - userlongitude) * 5761.674728278077 AS Distance FROM users WHERE Distance <= 2250000.0 ORDER BY Distance ASC

Your where clause needs to do a comparison to the same calculation you perform to get the result Distance, not to the name
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
Try to create a small app just with the api calls and a googlemap.
it wil be easier to find problems if you do not need to spent time on other issues.

I tried all my best trying to run exact solution in my local server but to no avail. I first wanted to understand your solution first before i talk about applying it in my code, but i am not getting it right with my local wamp server i have been using since for development.
1.
Under process global where you have:
B4X:
Public PhpPath As String = $"http://map.b4xcloud.de/"$

to (my local wireless ipv4  @ ipconfig at command prompt)

Public PhpPath As String = $"http://192.168.43.47/"$

2.
I also changed the one under, Sub MapFragment1_Ready:
from:
job.Download2("http://map.b4xcloud.de",

to:
job.Download2("http://192.168.43.47/",

3.
Under PHP, i changed your remote host settings from:

PHP:
$servername    = 'host';
$username    = 'd02e9e3d';
$password    = 'xxxxxx';
$dbname  = 'd02e9e3d';
include_once("./MysqliDb.php");
$db = new MysqliDb (Array ('host' => $servername,'username' => $username, 'password' => $password, 'db'=> $dbname, 'port' => 3306, 'prefix' => '', 'charset' => 'utf8'));
DEFINE ('base','1');

to

PHP:
<?php
$servername    = 'localhost';
$username    = 'root';
$password    = '';
$dbname  = 'test';
include_once("./MysqliDb.php");
$db = new MysqliDb (Array ('host' => $servername,'username' => $username, 'password' => $password, 'db'=> $dbname, 'port' => 3306, 'prefix' => '', 'charset' => 'utf8'));
DEFINE ('base','1');

Note: I ensured php PDO_Mysql and other related extensions are set for my wampserver to support mysqlidb.php and dbobject.php classes. I also ensured ports 80 and 3306 are configured for window firewall. I have twisted this into different areas to no avail. If there is anything different from remote host setting you hosted this solution that is different from what i am doing at moment. Please, with must respect for you, kindly let me know.

Other solutions i am trying right now:
1. I just downloaded latest version of wampserver so i can know if it is the problem
2. Another option is to get good emulator that supports google play service, so i can be able to trace where i am getting it wrong running your wonderful solution:
a. I have downloaded Genymotion and install successfully, but bringing this error: "...Genymotion requires a Graphic Card with 3D Acceleration and uptodate OpenGL with compatible driver", which i may open new thread for to seek solution aside using Virtual Machine/virtualization approach.
b. I have also installed all required and suggested SDK Manager files, but to start the inbuilt emulator is also generating ".../annotation/XmlSchema..." error, which may also require new thread to be opened.

Thank you, for your patience, immense contributions and sacrificing your precious time to render unconditional assistance!
Best Regards
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Your where clause needs
i just took the query @omo php script was using.
Your answer will be of help for omo for sure i guess :)
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
B4X:
Querying
SELECT userfname, usersurname, usersex, userpic, userlongitude, userlatitude, (46.95 - userlatitude) * (46.95 - userlatitude) * 12364.311711488797 + (7.44 - userlongitude) * (7.44 - userlongitude) * 5761.674728278077 AS Distance FROM users WHERE Distance <= 2250000.0 ORDER BY Distance ASC

Your where clause needs to do a comparison to the same calculation you perform to get the result Distance, not to the name

Thank you very much for your assistance, RVP,
I later suggested to DonManfred to use the query, so i can work on the remaining once i get his solution working for me. But, i am very grateful for the composure of that query. Is this the way i am going to put the query in PHP except for passing necessary variables from b4a which i am going to replace in your query above?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
kindly let me know
did you configured your router to forward requests to port x to your wampservers ip?
Also note that requests to a ip in your local network only works if you are connected to this netword too (wifi).

A webhosting is more easy to configure as you do not need to take care about portforwarding, open firewall and so on.

My example is working for you?

PD: Do you need much Databasedata for your project?

PD2: Note tht you should create a new thread for any new issue/problem you have.
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
did you configured your router to forward requests to port x to your wampservers ip?
Also note that requests to a ip in your local network only works if you are connected to this netword too (wifi).
No! I am not using router, i am just connecting to my local computer through android tethering hotspot.I use this approach very often especially when interfacing webview based apps to mysql database. The only ports i need to configure through window firewall in my case at moment are: 80 - for my Apache server and 3306 - for mysql ( although not normally necessary except the port is changed from default in local setting environment)

My example is working for you?
I have no doubt that you have done a fantastic job even at the speed of light (in less than 45 minutes, what took me several days before coming to forum to ask for help), the problem should be from my end i guess, if i can get this your solution working for me, i should be able to carry on with other issues as fast as possible.

Do you need much Databasedata for your project?
I have the sample database i sent together, what i may need is the information at the top of exported mysql database, so i can check your phpmyadmin version, php version, mysql version to know the kind of wampserver version to install (though i doubt if it my be the problem anyway)

Note tht you should create a new thread for any new issue/problem you have.
Yes, thank you, already noted. I will stick to that!
 
Upvote 0
Top