function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kerrie Tanksley 5Kerrie Tanksley 5 

Error: Unknown property 'Locations__cStandardController.Location__c'

Trying to display Google map on custom object. Works perfectly on another object called 'Members' but I'm getting this error on Locations object. Here is the code. Thank you for helping:

<apex:page standardController="Location__c">
<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4&sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?key='AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4'"></script>


<script type="text/javascript">

$(document).ready(function() {

 
  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;

 var marker;

 
  var geocoder = new google.maps.Geocoder();
  var address = "{!Location__c.Street__c} {!Locations__c.state__c} {!Locations__c.zip_code__c}";
  var infowindow = new google.maps.InfoWindow({
  content: " address + " "
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map

        map = new google.maps.Map(document.getElementById("map"), myOptions);
 
        //center map
        map.setCenter(results[0].geometry.Locations);
 
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.Locations,
            map: map,
            title: " "
        });
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {

        map.setCenter(marker.getPosition());
        });
 

      }

    } else {
      $('#map').css({'height' : '15px'});

     $('#map').html("Oops! address could not be found, please make sure the address is correct.");
      resizeIframe();

    }

 });
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;

        iframes[0].style.height = height + "px";

      }

    }

 }

});
</script>

 
<style>
#map {

  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;

  //min-width:300px;

  background:transparent;

}

</style>

</head>

<body>

<div id="map"></div>

</body>  

</apex:page>
Steven NsubugaSteven Nsubuga
Try this
<apex:page standardController="Location__c">
<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4&sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?key='AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4'"></script>


<script type="text/javascript">

$(document).ready(function() {

 
  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;

 var marker;

 
  var geocoder = new google.maps.Geocoder();
  var address = "{!Location__c.Street__c} {!Location__c.state__c} {!Location__c.zip_code__c}";
  var infowindow = new google.maps.InfoWindow({
  content: " address + " "
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map

        map = new google.maps.Map(document.getElementById("map"), myOptions);
 
        //center map
        map.setCenter(results[0].geometry.Locations);
 
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.Locations,
            map: map,
            title: " "
        });
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {

        map.setCenter(marker.getPosition());
        });
 

      }

    } else {
      $('#map').css({'height' : '15px'});

     $('#map').html("Oops! address could not be found, please make sure the address is correct.");
      resizeIframe();

    }

 });
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;

        iframes[0].style.height = height + "px";

      }

    }

 }

});
</script>

 
<style>
#map {

  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;

  //min-width:300px;

  background:transparent;

}

</style>

</head>

<body>

<div id="map"></div>

</body>  

</apex:page>

 
Kerrie Tanksley 5Kerrie Tanksley 5
Hey Steven,
Thank you so much for responding! I'm still getting the same error: Unknown property 'Locations__cStandardController.Location__c'

Any ideas?
Steven NsubugaSteven Nsubuga
Hi Kerrie, I am drawing a blank! 
My assumption was that you had used Locations__c rather than Location__c somewhere in your page.
 
Kerrie Tanksley 5Kerrie Tanksley 5
Yes you're correct... could that be part of the problem? When I set up the object I inadvertently put 'Locations' as the Object Name instead of 'Location'.

Label: Location
Plural Label: Locations
Object Name: Locations

 
Steven NsubugaSteven Nsubuga
In that case, change the visualforce page.
<apex:page standardController="Locations__c">
<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4&sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?key='AIzaSyDSLXBCASOqVNffD3Y0sOMutS2by-2CZZ4'"></script>


<script type="text/javascript">

$(document).ready(function() {

 
  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;
 var marker;

 
  var geocoder = new google.maps.Geocoder();
  var address = "{!Locations__c.Street__c} {!Locations__c.state__c} {!Locations__c.zip_code__c}";
  var infowindow = new google.maps.InfoWindow({
  content: " address + " "
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map

        map = new google.maps.Map(document.getElementById("map"), myOptions);
 
        //center map
        map.setCenter(results[0].geometry.Locations);
 
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.Locations,
            map: map,
            title: " "
        });
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {

        map.setCenter(marker.getPosition());
        });
 

      }

    } else {
      $('#map').css({'height' : '15px'});

     $('#map').html("Oops! address could not be found, please make sure the address is correct.");
      resizeIframe();

    }

 });
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;

        iframes[0].style.height = height + "px";

      }

    }

 }

});
</script>

 
<style>
#map {

  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;

  //min-width:300px;

  background:transparent;

}

</style>

</head>

<body>

<div id="map"></div>

</body>  

</apex:page>

 
Kerrie Tanksley 5Kerrie Tanksley 5
Okay, that got rid of the error message.... and thank you SO much for your help!!

BUT - NEW PROBLEM... there's only a blank space where the map is supposed to be displayed on the page. Any ideas? Again, this worked perfectly on another custom object!! UGH!
Steven NsubugaSteven Nsubuga
This one is harder to fix, since there is javascript involved.
Make sure that you have records in your Locations__c object, and that those records have data in the Street__c, state__c, zip_code__c fields.
Kerrie Tanksley 5Kerrie Tanksley 5
Yes, the address is in multiple records but the page only shows blank where the map should be. Any ideas.... anyone? I'll be a true hero if I can get this to work! Thanks in advance.
Steven NsubugaSteven Nsubuga
Make sure that you're using a valid Locations__c ID in the URL when you call this page. Make sure that the right Google Maps key is being used.