Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GeoIntegration
02-22-2016, 01:06 AM, (This post was last modified: 02-22-2016, 06:51 AM by janb.)
#1
GeoIntegration
GeoIntegration for Google Maps (v3) does not work for me with http requests (showing a blank map), only with https (SSL)
Has anyone else experienced this?
I can't see anything in API Manager (Google Developers Console) about SSL and whenever this is mandatory or not.
FYI i only accept SSL on my Apache Server for WebERP.

Changing SelectSupplier.php line 42 from:
Code:
echo '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . $api_key . '"';
to
Code:
echo '<script src="https://maps.google.com/maps?file=api&amp;v=2&amp;key=' . $api_key . '"';

The same with
geo_displaymap_suppliers.php Line 35
SelectCustomer.php Line 55
geo_displaymap_customers.php Line 35
geocode.php Line 40

..and everything looks good.

Update:
Found the source of this problem.
My web-browser is blocking "Mixed-Content"
Error message from javascript console:
Mixed Content: The page at https://(my server url) was loaded over HTTPS, but received an insecure script 'http://maps.googleapis.com/maps/api/js?key=xxxxx...'
This request has been blocked; the content must be served over HTTPS.


Suppose this could be fixed by using $_SERVER['HTTPS']
For example:
Code:
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
    $Map_Host = 'https://' . $myrow['map_host'];
} else {
    $Map_Host = 'http://' . $myrow['map_host'];
}

and change
Code:
echo '<script src="http://' . $Map_Host . '/maps/api/js?key=' . $Api_Key . '&sensor=false"';
to
Code:
echo '<script src="' . $Map_Host . '/maps/api/js?key=' . $Api_Key . '&sensor=false"';

Another minor problem in both SelectCustomer.php and SelectSupplier.php is that map does not show when a Customer or Supplier is selected from Search.
A message show: "Mapping is enabled, but no Mapping data to display for this Customer"
After a page refresh map shows up as it should.

Edit SelectSupplier.php at line 18 should fix this:

Code:
} else if (isset($_POST['Select']) AND $_POST['Select'] != 0) {
    $_SESSION['SupplierID']=$_POST['Select'];
}

For SelectCustomer.php its a bit more trickier
$_SESSION['CustomerID'] is not set before line 203.
Is it a problem moving this code lines up before geocode lines starting on line 28?
Code:
if (isset($_POST['JustSelectedACustomer'])) {
    /*Need to figure out the number of the form variable that the user clicked on */
    for ($i = 0; $i < count($_POST); $i++) { //loop through the returned customers
        if (isset($_POST['SubmitCustomerSelection' . $i])) {
            break;
        }
    } //end loop through $_POST array
    if ($i == count($_POST)) {
        prnMsg(_('Unable to identify the selected customer'), 'error');
    } else {
        $_SESSION['CustomerID'] = $_POST['SelectedCustomer' . $i];
        $_SESSION['BranchCode'] = $_POST['SelectedBranch' . $i];
    }
} // end if Just Selected A Customer

This works fine for me but it could of course be something I've overlooked..

Jan
Reply
02-29-2016, 11:48 PM,
#2
RE: GeoIntegration
Had a closer look at this and discovered a missing condition to the geocode SQL
Also, this script is using Goggle maps API v.2, should be upgraded to v.3

Code:
WHERE debtorsmaster.debtorno = '" . $_SESSION['CustomerID'] . "'
AND custbranch.branchcode = '" . $_SESSION['BranchCode'] . "'
Reply
03-01-2016, 11:02 AM,
#3
RE: GeoIntegration
Hi, Jan,

Thank you for your contribution, I'll commit your change later.
Best regards!

Exson
Reply
03-02-2016, 06:24 AM, (This post was last modified: 03-02-2016, 10:05 AM by janb.)
#4
RE: GeoIntegration
Thanks Exon

I have done some further modification to SelectCustomer.php for my own convenience.

* Some improvement to how to detect SubmitCustomerSelection
* Updated to Google Maps API v.3
* Updated Google Map links to https
* Integrated code lines from ceocode.php to update Customers (custbranch table) without lat (0) but width brpostaddr1
* Added code to show Branch Contact when branch is selected (beneath Customer Contacts)

If this is of interest i can submit this as a diff (after some cleanup)

Update: Done cleanup and submitted diff

Jan
Reply
03-02-2016, 11:25 AM,
#5
RE: GeoIntegration
Hi, Jan,

Thank you very much!

You can post it and I'll merge it to trunk when I return back to my office.

Thanks and best regards!

Exson
Reply
04-25-2016, 08:03 PM,
#6
RE: GeoIntegration
Just applied this ... sorry for the delay Jan!
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)