This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

AlbOKinG

  • **
  • 5 posts
  • www.TreguShqipetar.com
Help. For Google maps, location
« 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




http://www.tregushqipetar.com
« Last Edit: August 01, 2016, 10:09:40 PM by Armend Hirmete Uzairi »

*

MB Themes

Re: Help. For Google maps, location
« Reply #1 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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Schurli

  • **
  • 16 posts
Re: Help. For Google maps, location
« Reply #2 on: August 02, 2016, 08:13:21 AM »
@Armend Hirmete Uzairi
You have a Google API Key?

*

MB Themes

Re: Help. For Google maps, location
« Reply #3 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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Schurli

  • **
  • 16 posts
Re: Help. For Google maps, location
« Reply #4 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.

*

MB Themes

Re: Help. For Google maps, location
« Reply #5 on: August 02, 2016, 09:06:08 AM »
@Schurli
Thanks for solution ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

AlbOKinG

  • **
  • 5 posts
  • www.TreguShqipetar.com
Re: Help. For Google maps, location
« Reply #6 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/
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" 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', 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');

?>


Marked as best answer by frosticek on August 02, 2016, 10:14:49 PM
*

Schurli

  • **
  • 16 posts
Re: Help. For Google maps, location
« Reply #7 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

*

AlbOKinG

  • **
  • 5 posts
  • www.TreguShqipetar.com
Re: Help. For Google maps, location
« Reply #8 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?

*

AlbOKinG

  • **
  • 5 posts
  • www.TreguShqipetar.com
Re: Help. For Google maps, location
« Reply #9 on: August 02, 2016, 10:47:26 PM »
Schurli thank you for the help

*

MB Themes

Re: Help. For Google maps, location
« Reply #10 on: August 03, 2016, 08:12:39 AM »
@Armend Hirmete Uzairi
Was it solved with replacing index.php?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

AlbOKinG

  • **
  • 5 posts
  • www.TreguShqipetar.com
Re: Help. For Google maps, location
« Reply #11 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>';

Re: Help. For Google maps, location
« Reply #12 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


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

*

MB Themes

Re: Help. For Google maps, location
« Reply #13 on: September 28, 2016, 09:58:05 PM »
Did you try to use latest version of plugin from osclass?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Help. For Google maps, location
« Reply #14 on: October 07, 2016, 03:37:14 PM »
yes this is the latest version