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&v=2&key=' . $api_key . '"';
to
Code:
echo '<script src="https://maps.google.com/maps?file=api&v=2&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