Google Maps Using SSL

17 posts by 3 authors in: Forums > CMS Builder
Last Post: May 24, 2013   (RSS)

By nmsinc - May 13, 2013

I need some help securing a map page using Google Maps with Map pins - see code below - map shows with no pins! Any help would be appreciated - thanks NMSINC

<!-- Geocode for map -->
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
  var mapCanvasId = 'map_canvas';
  var mapOptions  = { mapTypeId: google.maps.MapTypeId.ROADMAP };
  var map         = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
  var bounds      = new google.maps.LatLngBounds();
  var infowindow  = new google.maps.InfoWindow();
  
<?php
$pinNum = 0;
foreach ($claims_submissionRecords as $record) {
$pinNum++; 
  if (!$record['latitude'] || !$record['longitude']) { continue; }
  $table1Record = mysql_get('accounts', $record['insurance_adjuster']);
  $table2Record = mysql_get('accounts', $record['independent_adjuster']);

  //default colors
  $pinColor  = "FFFFFF";
  $textColor = "000000";
 
  if ($CURRENT_USER['isAdmin'] AND $record['assign_to_independent_claim_company'] == "Yes" AND !$record['independent_adjuster'] ) {
  $pinColor  = "FFFFFF";
  $textColor = "000000";
  }
  elseif ($CURRENT_USER['isAdmin'] AND $record['assign_to_independent_claim_company'] == "No" AND!$record['insurance_adjuster'] || $CURRENT_USER['isAdmin'] AND !$record['assign_to_independent_claim_company'] AND!$record['insurance_adjuster']) {
  $pinColor  = "FFFFFF";
  $textColor = "000000";
  }
  elseif ($CURRENT_USER['isAdmin'] AND !$record['assign_to_independent_claim_company'] AND !$record['insurance_adjuster']) {
  $pinColor  = "FFFFFF";
  $textColor = "000000";
  }
  elseif ($CURRENT_USER['company_type'] == "Insurance" AND !$record['insurance_adjuster'] || $CURRENT_USER['company_type'] == "Insurance" AND $record['assign_to_independent_claim_company'] == "Yes" AND !$record['independent_adjuster']) {
  $pinColor  = "FFFFFF";
  $textColor = "000000";
  }
  elseif ($CURRENT_USER['company_type'] == "Independent" AND !$record['independent_adjuster']) {
  $pinColor  = "FFFFFF";
  $textColor = "000000";
  }
  elseif (!$record['independent_company_name'] || $record['assign_to_independent_claim_company'] == "No" || !$record['assign_to_independent_claim_company']) {
    $pinColor  = $table1Record['map_pin_color'];
    $textColor = $table1Record['map_pin_text_color'];
  }
  else {
    $pinColor  = $table2Record['map_pin_color'];
    $textColor = $table2Record['map_pin_text_color'];
  }
  $jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .escapeJs($record['_link']). "', {$pinNum}, '{$pinColor}', '{$textColor}'";
  print "  _geocoder_addMarker($jsFunctionArgs);\n";
}
 
 ?> 

  //
  function _geocoder_addMarker(latitude, longitude, recordNum, detailLink, pinNum, map_pin_color, map_pin_text_color) {
    var latLng       = new google.maps.LatLng(latitude, longitude);
    var infowindowEl = document.getElementById('marker_infowindow_' + recordNum);
    var image        = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld="+pinNum+"|"+map_pin_color+"|"+map_pin_text_color;
    var marker       = new google.maps.Marker({ map: map, position: latLng, icon:image });
    google.maps.event.addListener(marker, 'click', function() {
      if (infowindowEl) {
        infowindow.setContent(infowindowEl.innerHTML);
        infowindow.open(map, marker);
      }
      else {
        window.location = detailLink;
      }
    });
    bounds.extend(latLng);
  }

  //
  map.fitBounds(bounds);
}

</script>

<link href="css/style.css" rel="stylesheet" type="text/css" />
  <script type = "text/javascript" src = "../cmsAdmin/3rdParty/jquery/jquery1.4.1.js"></script>
  <script type = "text/javascript">
      function populateAdjusterListMap(company, target) {
 
 ajaxUrl = "populateAdjusterListMap.php?company="+escape(company.value)+"&target="+escape(target);
     
 $.get(ajaxUrl, function(html){
          $('#'+target).html( html );
        });
 
      }
    </script>
<!-- New Populate Script -->

<script type = "text/javascript">

      function populateListsIns(member) {
            ajaxUrl = "dispatcherList.php?num="+escape(member.value);
            $.get(ajaxUrl, function(html){
              $('#insdispatcher_drop').html( html );
            });
            ajaxUrl = "adjusterList.php?num="+escape(member.value);
            $.get(ajaxUrl, function(html){
              $('#insadjuster_drop').html( html );
           });
       }

    </script>
   
    <script type = "text/javascript">

      function populateListsInd(member) {
            ajaxUrl = "dispatcherList.php?num="+escape(member.value);
            $.get(ajaxUrl, function(html){
              $('#inddispatcher_drop').html( html );
            });
            ajaxUrl = "adjusterList.php?num="+escape(member.value);
            $.get(ajaxUrl, function(html){
              $('#indadjuster_drop').html( html );
           });
       }

    </script>

nmsinc

By Dave - May 13, 2013

Hi nmsinc, 

Here's my first guess... Try replacing both https:// and "http:// with just // so they load using the same protocol (or if that doesn't work https://).

It looks weird but this is valid HTML:
<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>

And
var image        = "//chart.apis.google.com/chart?chst=d_map_pin_letter&chld="+pinNum+"|"+map_pin_color+"|"+map_pin_text_color;

Let me know if that works.

Dave Edis - Senior Developer
interactivetools.com

By nmsinc - May 14, 2013

Hi Dave,

Everything works with the exception of the map pins - the map pins do not show!

Thanks - NMSINC

nmsinc

By gregThomas - May 14, 2013

Hi NMSINC,

Do you have a link to a page we can see the map on? Do you get any JavaScript errors when you look in the JavaScript console (press ctrl+shift+j to view it in Chrome).

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By nmsinc - May 14, 2013

The page is user secured, can you provide a email address so I can provide you a user ID and password?

Thanks - NMSINC

nmsinc

By gregThomas - May 14, 2013

If you fill in a second level support request form I'll be able to send you my e-mail address from there, or you can add the ID and password to the summary of problem area. You can find the form here:

https://www.interactivetools.com/support/email_support_form.php

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - May 21, 2013

Hi NMSINC,

I did reply to your support ticket with the fixes I'd made. Could you check your spam folder for the message? You should find that one of your map pages is working correctly now.

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By nmsinc - May 21, 2013

Hi Greg,

Found your emails in spam - sorry - I did check and the map pins only show when the user accepts all non secure content - any other ideas on this?

Thanks - nmsinc

nmsinc

By gregThomas - May 22, 2013

Hi,

Which browser are you using? When I was testing I used Daves suggestion on this thread to ensure the google map JS file was delivered via HTTPS

Would you mind filling out another second level support request with the sites details again? You can find the form here:

https://www.interactivetools.com/support/email_support_form.php

As we closed the previous ticket and no longer have the FTP/login info for the site.

Thanks!

Greg 

Greg Thomas







PHP Programmer - interactivetools.com