PHP code example of joomla / openstreetmap

1. Go to this page and download the library: Download joomla/openstreetmap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

joomla / openstreetmap example snippets


use Joomla\OpenStreetMap\OpenStreetMap;

$osm = new OpenStreetMap;

use Joomla\Http\Http;
use Joomla\OpenStreetMap\OAuth;
use Joomla\OpenStreetMap\OpenStreetMap;

$key    = 'your_key';
$secret = 'your_secret';

$options = array('consumer_key' => $key, 'consumer_secret' => $secret, 'sendheaders' => true);

$client = new Http;

$application = $this->getApplication();

$oauth = new OAuth($options, $client, $application->input, $application);
$oauth->authenticate();

$osm = new OpenStreetMap($oauth);

$element = $osm->elements;
$result = $element->readElement('node', 123);

// To view the \SimpleXMLElement object
print_r($result);

use Joomla\Http\Http;
use Joomla\OpenStreetMap\OAuth;
use Joomla\OpenStreetMap\OpenStreetMap;

$key    = 'your_key';
$secret = 'your_secret';

$options = array('consumer_key' => $key, 'consumer_secret' => $secret, 'sendheaders' => true);

$client = new Http;

$application = $this->getApplication();

$oauth = new OAuth($options, $client, $application->input, $application);
$oauth->authenticate();

$osm = new OpenStreetMap($oauth);

$changeset = $osm->changesets;

$changesets = array(
	'comment'    => 'My First Changeset',
	'created_by' => 'JoomlaOpenStreetMap'
);

$result = $changeset->createChangeset($changesets);

// Returned value contains the identifier of new changeset
print_r($result);