Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
f0fabfb1
Commit
f0fabfb1
authored
15 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Add class to manage Google API
parent
f1cb94b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/lib/google.class.php
+80
-0
80 additions, 0 deletions
htdocs/lib/google.class.php
with
80 additions
and
0 deletions
htdocs/lib/google.class.php
0 → 100644
+
80
−
0
View file @
f0fabfb1
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/lib/google.class.php
* \brief A set of functions for using Google APIs
* \version $Id$
*/
class
GoogleAPI
{
var
$db
;
var
$error
;
var
$key
;
/**
* Constructor
*
* @param db Database handler
* @param string Google key
* @return GoogleAPI
*/
function
GoogleAPI
(
$DB
,
$key
)
{
$this
->
db
=
$DB
;
$this
->
key
=
$key
;
}
/**
* \brief Return geo coordinates of an address
* \param address Address
* Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
* Example: 188, rue de Fontenay,+94300,+Vincennes,+France
* \return string Coordinates
*/
function
getGeoCoordinatesOfAddress
(
$address
)
{
global
$conf
;
$i
=
0
;
// Desired address
$urladdress
=
"http://maps.google.com/maps/geo?q="
.
urlencode
(
$address
)
.
"&output=xml&key="
.
$this
->
key
;
// Retrieve the URL contents
$page
=
file_get_contents
(
$urladdress
);
$code
=
strstr
(
$page
,
'<coordinates>'
);
$code
=
strstr
(
$code
,
'>'
);
$val
=
strpos
(
$code
,
"<"
);
$code
=
substr
(
$code
,
1
,
$val
-
1
);
//print $code;
//print "<br>";
$latitude
=
substr
(
$code
,
0
,
strpos
(
$code
,
","
));
$longitude
=
substr
(
$code
,
strpos
(
$code
,
","
)
+
1
,
strlen
(
strpos
(
$code
,
","
))
-
3
);
// Output the coordinates
//echo "Longitude: $longitude ',' Latitude: $latitude";
$i
++
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment