Osclass Support Forums

Osclass theme support => Free themes => Patricia Osclass Responsive Theme => Topic started by: AlbOKinG on August 01, 2016, 10:07:43 PM

Title: Help. For Google maps, location
Post by: AlbOKinG on August 01, 2016, 10:07:43 PM
I need help around the location with google maps. I do not know why not open? Where is the problem. Who can you helped
thank you


(https://s32.postimg.org/stqx0o6jp/sssssssssssssssssssjpg.jpg)

http://www.tregushqipetar.com
Title: Re: Help. For Google maps, location
Post by: MB Themes on August 01, 2016, 10:37:04 PM
@Armend Hirmete Uzairi
You have javascript errors in your site.
Check them.
And also check for latest version, it is osclass plugin, not ours.
Title: Re: Help. For Google maps, location
Post by: Schurli on August 02, 2016, 08:13:21 AM
@Armend Hirmete Uzairi
You have a Google API Key?
Title: Re: Help. For Google maps, location
Post by: MB Themes on August 02, 2016, 08:14:35 AM
@Schruli
No, I am not using it.
I know it was not required, but in last year google was warning (it was seen in console as well) that there is missing api key and you should get it.... maybe it is going to be required.
Title: Re: Help. For Google maps, location
Post by: Schurli on August 02, 2016, 08:56:19 AM
@Armend Hirmete Uzairi
Go to Google Maps Plugin, open the index.php, search
Code: [Select]
echo '<script src="https://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>'; in Line 20, and change to
Code: [Select]
echo '<script src="https://maps.google.com/maps/api/js?key=Your-API-Key-from-Google&sensor=false" type="text/javascript"></script>'; and it Works fine.
Title: Re: Help. For Google maps, location
Post by: MB Themes on August 02, 2016, 09:06:08 AM
@Schurli
Thanks for solution ;)
Title: Re: Help. For Google maps, location
Post by: AlbOKinG on August 02, 2016, 09:06:22 PM
@Armend Hirmete Uzairi
Go to Google Maps Plugin, open the index.php, search
Code: [Select]
echo '<script src="https://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>'; in Line 20, and change to
Code: [Select]
echo '<script src="https://maps.google.com/maps/api/js?key=Your-API-Key-from-Google&sensor=false" type="text/javascript"></script>'; and it Works fine.

Schurli friend.
Effekt has not though I did change. probably did not know where to
be the problem.


<?php
/*
Plugin Name: Google Maps
Plugin URI: http://www.osclass.org/ (http://www.osclass.org/)
Description: This plugin shows a Google Map on the location space of every item.
Version: 2.1.6
Author: Osclass & kingsult

*/

    function google_maps_location() {
        $item = osc_item();
        osc_google_maps_header();
        require 'map.php';
    }

    // HELPER
    function osc_google_maps_header() {
        echo '<script src="https://maps.google.com/maps/api/js?key=AIzaSyBENDJnnVw6QCgKVoZBqZp79kYsCRh6BB4&sensor=false (https://maps.google.com/maps/api/js?key=AIzaSyBENDJnnVw6QCgKVoZBqZp79kYsCRh6BB4&sensor=false)" type="text/javascript"></script>';
        echo '<style>#itemMap img { max-width: 140em; } </style>';
    }

    function insert_geo_location($item) {
        $itemId = $item['pk_i_id'];
        $aItem = Item::newInstance()->findByPrimaryKey($itemId);
        $sAddress = (isset($aItem['s_address']) ? $aItem['s_address'] : '');
        $sCity = (isset($aItem['s_city']) ? $aItem['s_city'] : '');
        $sRegion = (isset($aItem['s_region']) ? $aItem['s_region'] : '');
        $sCountry = (isset($aItem['s_country']) ? $aItem['s_country'] : '');
        $address = sprintf('%s, %s, %s, %s', $sAddress, $sCity, $sRegion, $sCountry);
        $response = osc_file_get_contents(sprintf('http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false (http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false)', urlencode($address)));
        $jsonResponse = json_decode($response);
        if (isset($jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
            $coord = $jsonResponse->Placemark[0]->Point->coordinates;
            ItemLocation::newInstance()->update (array('d_coord_lat' => $coord[1]
                                                      ,'d_coord_long' => $coord[0])
                                                ,array('fk_i_item_id' => $itemId));
        }
    }

    osc_add_hook('location', 'google_maps_location');

    osc_add_hook('posted_item', 'insert_geo_location');
    osc_add_hook('edited_item', 'insert_geo_location');

?>

Title: Re: Help. For Google maps, location
Post by: Schurli on August 02, 2016, 10:04:16 PM
This is my index.php
Code: [Select]
<?php
/*
Plugin Name: Google Maps
Plugin URI: http://www.osclass.org/
Description: This plugin shows a Google Map on the location space of every item.
Version: 2.1.6
Author: Osclass & kingsult
Author URI: http://www.osclass.org/
Plugin update URI: http://www.osclass.org/files/plugins/google_maps/update.php
*/

    
function google_maps_location() {
        
$item osc_item();
        
osc_google_maps_header();
        require 
'map.php';
    }

    
// HELPER
    
function osc_google_maps_header() {
        echo 
'<script src="https://maps.google.com/maps/api/js?key=AIzaSyC86j93jSD1utlzg8egiVn5qMWUqktN2_s&sensor=false" type="text/javascript"></script>';
        echo 
'<style>#itemMap img { max-width: 140em; } </style>';
    }

    function 
insert_geo_location($item) {
        
$itemId $item['pk_i_id'];
        
$aItem Item::newInstance()->findByPrimaryKey($itemId);
        
$sAddress = (isset($aItem['s_address']) ? $aItem['s_address'] : '');
        
$sCity = (isset($aItem['s_city']) ? $aItem['s_city'] : '');
        
$sRegion = (isset($aItem['s_region']) ? $aItem['s_region'] : '');
        
$sCountry = (isset($aItem['s_country']) ? $aItem['s_country'] : '');
        
$address sprintf('%s, %s, %s, %s'$sAddress$sCity$sRegion$sCountry);
        
$response osc_file_get_contents(sprintf('http://maps.google.com/maps/geo?q=%s&output=json&sensor=false'urlencode($address)));
        
$jsonResponse json_decode($response);
        if (isset(
$jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
            
$coord $jsonResponse->Placemark[0]->Point->coordinates;
            
ItemLocation::newInstance()->update (array('d_coord_lat' => $coord[1]
                                                      ,
'd_coord_long' => $coord[0])
                                                ,array(
'fk_i_item_id' => $itemId));
        }
    }

    
osc_add_hook('location''google_maps_location');

    
osc_add_hook('posted_item''insert_geo_location');
    
osc_add_hook('edited_item''insert_geo_location');

?>

It works perfect
Title: Re: Help. For Google maps, location
Post by: AlbOKinG on August 02, 2016, 10:33:55 PM
Hm that the work that I do not know? what could be....!
Maybe I should an older version?
Title: Re: Help. For Google maps, location
Post by: AlbOKinG on August 02, 2016, 10:47:26 PM
Schurli thank you for the help
Title: Re: Help. For Google maps, location
Post by: MB Themes on August 03, 2016, 08:12:39 AM
@Armend Hirmete Uzairi
Was it solved with replacing index.php?
Title: Re: Help. For Google maps, location
Post by: AlbOKinG on August 16, 2016, 12:39:54 AM
@frosticek
I chose was the problem that google api key

echo '<script src="https://maps.google.com/maps/api/js?key=Your-API-Key-from-Google&sensor=false" type="text/javascript"></script>';
Title: Re: Help. For Google maps, location
Post by: Paulo Ribeiro on September 28, 2016, 03:48:26 PM
I have this problem and using the key i still get the error that i'm not using the key:

please check the website http://coveto.net/para-venda/animais/escalares-altum-peruensis_i14 (http://coveto.net/para-venda/animais/escalares-altum-peruensis_i14)


Code: [Select]
    // HELPER
    function osc_google_maps_header() {
        echo '<script src="https://maps.google.com/maps/api/js?key=AIzaSyD5EuFUQKQNWpLvprJJ4hh-KBdmF-FSaWQ&sensor=false" type="text/javascript"></script>';
        echo '<style>#itemMap img { max-width: 140em; } </style>';
    }

i have no idea why it still fails. the key is valid and authorized to run there.
i also saw people saying to add v=3 and i tried and does nothing
please help
Title: Re: Help. For Google maps, location
Post by: MB Themes on September 28, 2016, 09:58:05 PM
Did you try to use latest version of plugin from osclass?
Title: Re: Help. For Google maps, location
Post by: Paulo Ribeiro on October 07, 2016, 03:37:14 PM
yes this is the latest version
Title: Re: Help. For Google maps, location
Post by: MB Themes on October 07, 2016, 03:56:33 PM
@Paulo
Then it is problem that osclass did not care yet.
Title: Re: Help. For Google maps, location
Post by: SaticiAlici.Com on March 16, 2020, 06:48:09 PM
This is my index.php
Code: [Select]
<?php
/*
Plugin Name: Google Maps
Plugin URI: http://www.osclass.org/
Description: This plugin shows a Google Map on the location space of every item.
Version: 2.1.6
Author: Osclass & kingsult
Author URI: http://www.osclass.org/
Plugin update URI: http://www.osclass.org/files/plugins/google_maps/update.php
*/

    
function google_maps_location() {
        
$item osc_item();
        
osc_google_maps_header();
        require 
'map.php';
    }

    
// HELPER
    
function osc_google_maps_header() {
        echo 
'<script src="https://maps.google.com/maps/api/js?key=AIzaSyC86j93jSD1utlzg8egiVn5qMWUqktN2_s&sensor=false" type="text/javascript"></script>';
        echo 
'<style>#itemMap img { max-width: 140em; } </style>';
    }

    function 
insert_geo_location($item) {
        
$itemId $item['pk_i_id'];
        
$aItem Item::newInstance()->findByPrimaryKey($itemId);
        
$sAddress = (isset($aItem['s_address']) ? $aItem['s_address'] : '');
        
$sCity = (isset($aItem['s_city']) ? $aItem['s_city'] : '');
        
$sRegion = (isset($aItem['s_region']) ? $aItem['s_region'] : '');
        
$sCountry = (isset($aItem['s_country']) ? $aItem['s_country'] : '');
        
$address sprintf('%s, %s, %s, %s'$sAddress$sCity$sRegion$sCountry);
        
$response osc_file_get_contents(sprintf('http://maps.google.com/maps/geo?q=%s&output=json&sensor=false'urlencode($address)));
        
$jsonResponse json_decode($response);
        if (isset(
$jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
            
$coord $jsonResponse->Placemark[0]->Point->coordinates;
            
ItemLocation::newInstance()->update (array('d_coord_lat' => $coord[1]
                                                      ,
'd_coord_long' => $coord[0])
                                                ,array(
'fk_i_item_id' => $itemId));
        }
    }

    
osc_add_hook('location''google_maps_location');

    
osc_add_hook('posted_item''insert_geo_location');
    
osc_add_hook('edited_item''insert_geo_location');

?>

It works perfect

Thank you, yes works perfect :)
Title: Re: Help. For Google maps, location
Post by: SaticiAlici.Com on March 16, 2020, 08:06:50 PM
This is my index.php
Code: [Select]
<?php
/*
Plugin Name: Google Maps
Plugin URI: http://www.osclass.org/
Description: This plugin shows a Google Map on the location space of every item.
Version: 2.1.6
Author: Osclass & kingsult
Author URI: http://www.osclass.org/
Plugin update URI: http://www.osclass.org/files/plugins/google_maps/update.php
*/

    
function google_maps_location() {
        
$item osc_item();
        
osc_google_maps_header();
        require 
'map.php';
    }

    
// HELPER
    
function osc_google_maps_header() {
        echo 
'<script src="https://maps.google.com/maps/api/js?key=AIzaSyC86j93jSD1utlzg8egiVn5qMWUqktN2_s&sensor=false" type="text/javascript"></script>';
        echo 
'<style>#itemMap img { max-width: 140em; } </style>';
    }

    function 
insert_geo_location($item) {
        
$itemId $item['pk_i_id'];
        
$aItem Item::newInstance()->findByPrimaryKey($itemId);
        
$sAddress = (isset($aItem['s_address']) ? $aItem['s_address'] : '');
        
$sCity = (isset($aItem['s_city']) ? $aItem['s_city'] : '');
        
$sRegion = (isset($aItem['s_region']) ? $aItem['s_region'] : '');
        
$sCountry = (isset($aItem['s_country']) ? $aItem['s_country'] : '');
        
$address sprintf('%s, %s, %s, %s'$sAddress$sCity$sRegion$sCountry);
        
$response osc_file_get_contents(sprintf('http://maps.google.com/maps/geo?q=%s&output=json&sensor=false'urlencode($address)));
        
$jsonResponse json_decode($response);
        if (isset(
$jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
            
$coord $jsonResponse->Placemark[0]->Point->coordinates;
            
ItemLocation::newInstance()->update (array('d_coord_lat' => $coord[1]
                                                      ,
'd_coord_long' => $coord[0])
                                                ,array(
'fk_i_item_id' => $itemId));
        }
    }

    
osc_add_hook('location''google_maps_location');

    
osc_add_hook('posted_item''insert_geo_location');
    
osc_add_hook('edited_item''insert_geo_location');

?>

It works perfect

I noticed, your API Code working but my code not wroking :(