+ Start a Discussion
maiyakumaiyaku 

Google Maps not show when add latitude and longitude

I try to add latitude and longitude to google maps. but it not show.

I would like to use latitude, longitude without the address ?

 

Page

<apex:page standardController="Sales_Visit__c">

<c:GoogleMapsInternational 
    latitude="{!Sales_Visit__c.Latitude__c}" 
    longitude="{!Sales_Visit__c.Longitude__c}" 
    iconColour="#236FBD"
    width="700"
    height="700"
    
    backgroundColour="#FFFFFF" />
</apex:page>

 Component

<apex:component >

    <apex:attribute name="googleMapAPIKey" description="Google maps API key needed to generate map, sign up at http://code.google.com/apis/maps/signup.html"
        type="string" default="CHANGE_ME"/>
        
    <apex:attribute name="googleMapURL" description="URL of Google map for example http://maps.google.com, http://maps.google.fr, http://maps.google.es, http://maps.google.co.uk, etc"
        type="string" />
    <apex:attribute name="height" description="Google map height in pixels"
        type="integer" default="200" />
    <apex:attribute name="width" description="Google map width in pixels"
        type="integer" default="700" />
    <apex:attribute name="latitude" description="Current latitude"
        type="Double" />
    <apex:attribute name="longitude" description="Current longitude"
        type="Double" />
    <apex:attribute name="iconColour" description="Colour of icon marker in map for example #236FBD and #8A9EBE (colours for account)and #56458C (colours for contact)"
        type="string" default="#FF0000" />
    <apex:attribute name="backgroundColour" description="Background Colour around the Google Map for example set to #FFFFFF to change from default salesforce background colour"
        type="string" default="#F3F3EC" />
    <apex:attribute name="address" description="Address to search for in Google maps, including the country in the address helps accuraccy"
        type="string"  />

    <apex:outputPanel id="top_level_panel" layout="block" style="background-color: {!backgroundColour}; margin-left: auto; margin-right: auto">
        <apex:outputPanel id="map_canvas" layout="block" style="width: {!width}px; height: {!height}px; margin-left: auto; margin-right: auto">
        </apex:outputPanel>
    </apex:outputPanel>

    <div id="hiddenFieldAddress" style="display:none">{!address}</div>
    <div id="hiddenFieldLocalAddressFound" style="display:none">{!$Label.GMI_LocalAddressFound}</div>
    <div id="hiddenFieldLocalAddressNotFound" style="display:none">{!$Label.GMI_LocalAddressNotFound}</div>
    <div id="hiddenFieldLocalShowMap" style="display:none">{!$Label.GMI_LocalShowMap}</div>
    <div id="hiddenFieldErrorHeader" style="display:none">{!$Label.GMI_GenerateKey}</div>  
    <div id="hiddenFieldErrorDetails" style="display:none">{!$Label.GMI_UpdateComponent}</div>
    <div id="hiddenFieldErrorWebsite" style="display:none">{!$Label.GMI_WebsiteNeeded}</div>

    <div id="hiddenFieldGoogleLanguageCode" style="display:none">{!$Label.GMI_GoogleLanguageCode}</div>
    <div id="hiddenFieldgoogleMapURL" style="display:none">{!$Label.GMI_googleMapURL}</div>
    <div id="hiddenFieldgoogleMapURLOverride" style="display:none">{!googleMapURL}</div>
    
    <div id="hiddenFieldLatitude" style="display:none">{!latitude}</div>
    <div id="hiddenFieldLongitude" style="display:none">{!longitude}</div>
       
    <script type="text/javascript">

        var safeAddress = document.getElementById('hiddenFieldAddress').innerHTML.replace(/\s+/g, ' ');
        var safelatitude = document.getElementById('hiddenFieldLatitude').innerHTML.replace(/\s+/g, ' ');
        var safelongitude = document.getElementById('hiddenFieldLongitude').innerHTML.replace(/\s+/g, ' ');

        var safeLocalAddressFound = document.getElementById('hiddenFieldLocalAddressFound').innerHTML.replace(/\s+/g, ' ');
        var safeLocalAddressNotFound = document.getElementById('hiddenFieldLocalAddressNotFound').innerHTML.replace(/\s+/g, ' ');
        var safeLocalShowMap = document.getElementById('hiddenFieldLocalShowMap').innerHTML.replace(/\s+/g, ' ');
        var safeErrorHeader = document.getElementById('hiddenFieldErrorHeader').innerHTML.replace(/\s+/g, ' ');
        var safeErrorDetails = document.getElementById('hiddenFieldErrorDetails').innerHTML.replace(/\s+/g, ' ');
        var safeErrorWebsite = document.getElementById('hiddenFieldErrorWebsite').innerHTML.replace(/\s+/g, ' ');
        var safeGoogleLanguageCode = document.getElementById('hiddenFieldGoogleLanguageCode').innerHTML.replace(/\s+/g, ' ');

    </script>

    <script type="text/javascript">
        // see if Google api URL override has been set
        var safeGoogleMapURL = document.getElementById('hiddenFieldgoogleMapURL').innerHTML.replace(/\s+/g, ' ');
        var safeGoogleMapURLOverride = document.getElementById('hiddenFieldgoogleMapURLOverride').innerHTML.replace(/\s+/g, ' ');
        if (safeGoogleMapURLOverride != "")
        {
            safeGoogleMapURL = safeGoogleMapURLOverride;
        }
        //change google api
        document.write('<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&aLoc={!latitude}&zLoc={!longitude}&key=ABQIAAAAqxV-CxuhXx_fdbYnCi75TxSwuLiTNBOhuAjJ8jE06OTy4MFh9BS9pLQLodvQx9Odv8UPA6g4H7Y6Aw"><\/scr' + 'ipt>');  
   </script>


    <script src="{!URLFOR($Resource.GoogleMapsInternational, 'googleMapsInternational.js')}" type="text/javascript"></script>
    <script type="text/javascript">
                
    // run initialize
    initialize(  safelatitude, '{!latitude}', safelongitude , '{!longitude}', '{!iconColour}', safeGoogleMapURL, '{!width}', '{!height}', safeGoogleLanguageCode, safeLocalAddressFound, safeLocalAddressNotFound, safeLocalShowMap, safeErrorHeader, safeErrorDetails, safeErrorWebsite, '{!$Component.map_canvas}' );        
            
    </script>

</apex:component>

 Thank you.

Rajesh SriramuluRajesh Sriramulu

Hi

 

 

U didn't get teh Api key in component if u r installed the Salesforce International Mapping using Google Maps then get Api key and paste in componet.click  https://accounts.google.com/ServiceLogin?service=devconsole&passive=1209600&continue=https://code.google.com/apis/console/&followup=https://code.google.com/apis/console/  login with ur gmail account and create Api key and paste in default="   " />

 

 

<apex:attribute name="googleMapAPIKey" description="Google maps API key needed to generate map, sign up at http://code.google.com/apis/maps/signup.html"
        type="string" default="API KEY "/>
        

maiyakumaiyaku

I change API Key to defulat . but not show 

 

 <apex:attribute name="googleMapAPIKey" description="Google maps API key needed to generate map, sign up at http://code.google.com/apis/maps/signup.html"
        type="string" default="AIzaSyD4YXCAs5ppFZfC1yUAx8rJL2No6pEGYNw"/>

 Thank you.

Rajesh SriramuluRajesh Sriramulu

Hi

 

As I think this vf page has to be added to Sales_Visit__c page layout and when u create a record for Sales_Visit__c google map  will appear and here u have to give the access of  this vf page to ur profile,so that it will appear.

 

 

Regards,

Rajesh.