• LuckyOne
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hi,
I am already have right code to get goole map from the custom object when street, surbub, city and country all fill in.
So, my question is:
if this custom object have another field which is called geolocation (latitude, longtitude).

How can I get map from geolocation first, if geolocation is empty or have errors, then run my code(showing below) to get map from those field( street, surbub, city and country)

could you give me another part of code which is getting map from geolocation:)

Thanks,
<apex:page standardController="Location__c">

<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></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.city__c} {!Location__c.Suburb__c} {!Location__c.Country__c}";
  var infowindow = new google.maps.InfoWindow({
  content: "<b>{!Location__c.Name}</b><br>" + 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.location);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{Location__c.Name__c}"
        });

        //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>

 
Hi All,

There is a problem about out of office auto reply------when someone out of office, and if there has a topic on chatter and have people reply this topic, then this gay will auto reply lots of time that message: I am out of office from now to .........

Is that any possible can stop this>?
Hi all,

I just wanna say Thanks First that people who want help me out.

There is a custom application that I want delete it, but It showing that "Unable to delete custom app. Profiles are using this custom app as default".

Because in my salesforce, there has more than 80 profile, so if is a way needs modify profile, do you have easy way to modify those 80 profile at the same time? 

I think if just change one profile it cant delete also.

Or other way can delete custom app>?

Thanks 
Hi,
I am already have right code to get goole map from the custom object when street, surbub, city and country all fill in.
So, my question is:
if this custom object have another field which is called geolocation (latitude, longtitude).

How can I get map from geolocation first, if geolocation is empty or have errors, then run my code(showing below) to get map from those field( street, surbub, city and country)

could you give me another part of code which is getting map from geolocation:)

Thanks,
<apex:page standardController="Location__c">

<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></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.city__c} {!Location__c.Suburb__c} {!Location__c.Country__c}";
  var infowindow = new google.maps.InfoWindow({
  content: "<b>{!Location__c.Name}</b><br>" + 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.location);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{Location__c.Name__c}"
        });

        //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>

 
Hi all,

I just wanna say Thanks First that people who want help me out.

There is a custom application that I want delete it, but It showing that "Unable to delete custom app. Profiles are using this custom app as default".

Because in my salesforce, there has more than 80 profile, so if is a way needs modify profile, do you have easy way to modify those 80 profile at the same time? 

I think if just change one profile it cant delete also.

Or other way can delete custom app>?

Thanks