This topic is locked

GPS location

11/16/2017 4:54:55 PM
PHPRunner General questions
mtpocket author

Greetings,
Objective to determine the GPS coordinates of a user logging in via mobile device.
I have a table:-

  • ID (INT)
  • geo_address (text)
  • geo_lat (double)
  • geo_long (double)
    Only when I add the address does the geo_lat & geo_long insert the coordinates but I don't want to put in the address, only capture coordinates which should correctly display on the map.

    I've followed examples & cannot just seem to succeed. Managed to get the MAP API & Geocoding incorporated into the project. I'm using PHPRunner 8.1
    I even ran ?geocoding=1 & it has errors. As I said works when I put in an address.
    Thanks

    <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=25156&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />

romaldus 11/17/2017

You can use the mapy plugin which is available in xlinesoft marketplace:
https://xlinesoft.com/marketplace/products_view.php?editid1=51
Live Demo:

http://www.mibarbol.besaba.com/mapy/geo_add.php

mtpocket author 11/17/2017



You can use the mapy plugin which is available in xlinesoft marketplace:
https://xlinesoft.com/marketplace/products_view.php?editid1=51
Live Demo:

http://www.mibarbol.besaba.com/mapy/geo_add.php


Thanks Romaldus for the quick response really appreciated. Are you sure about this plugin? It says you can pick a point from map & it returns your coordinates, it should automatically get coordinates when a user adds or amends a record. I'll mail Mario to verify.
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=83738&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thanks

romaldus 11/17/2017



Thanks Romaldus for the quick response really appreciated. Are you sure about this plugin? It says you can pick a point from map & it returns your coordinates, it should automatically get coordinates when a user adds or amends a record. I'll mail Mario to verify.
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=83740&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thanks


Of course. I use this plugin for my projects.

Mapy Plugin uses only one database field to store coordinat, separated by semicolon (for example 40.71277530000001; -74.00606063068852)

mtpocket author 11/17/2017



Of course. I use this plugin for my projects.

Mapy Plugin uses only one database field to store coordinat, separated by semicolon (for example 40.71277530000001; -74.00606063068852)


Thanks Romaldus, just to reiterate the question. My user logs into the system with mobile device, I don't have the users address at all, the user adds a record & I need to determine what the GPS coordinates are. Is this how it's being used in your projects or do you require an address to be input mandatory?
In the live demo you have to input an address before you can get the coordinates, lat & long.
Thanks

romaldus 11/18/2017

Unfortunately it is not possible to capture user Geolocation (lat, long) automatically.

Most modern web browsers requires user permission to share their location.
The following resources may help :
https://stackoverflo...cation-to-allow
https://www.w3school...geolocation.asp

admin 11/20/2017

Here is the sample code you can use in Javascript OnLoad event:

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(showPosition);

}

function showPosition(position) {

alert("Latitude: " + position.coords.latitude +

" Longitude: " + position.coords.longitude);

}


It will ask for users permission to provide location. It will only happen once and once permission is granted this popup won't appear on subsequent page loads.

mtpocket author 11/21/2017



Here is the sample code you can use in Javascript OnLoad event:

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(showPosition);

}

function showPosition(position) {

alert("Latitude: " + position.coords.latitude +

" Longitude: " + position.coords.longitude);

}


It will ask for users permission to provide location. It will only happen once and once permission is granted this popup won't appear on subsequent page loads.


Thanks admin,
I've managed that but how can I insert those 2 fields into my database?
Thanks.