Thursday, June 7, 2012

Multiple address on Visualforce Page with GMAP in apex salesforce

Hi guys ,

Look at standard visualforce page for showing multiple address on Gmap.

<apex:page standardController="Account" sidebar="false">
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
            var map = null;
            var geocoder = null;          
            function initialize() {
                if (GBrowserIsCompatible()) {
                    map = new GMap2(document.getElementById("map_canvas"));
                    map.setCenter(new GLatLng(24.957639, 46.698775), 4);
                    geocoder = new GClientGeocoder();
                    map.setUIToDefault();                  
                }
            }

            function createMarker(point,address)
            {   
                // Create our "tiny" marker icon
                var blueIcon = new GIcon(G_DEFAULT_ICON);
                blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/green/blank.png";
                blueIcon.iconSize = new GSize(32, 32)
                // Set up our GMarkerOptions object
                markerOptions = { icon:blueIcon };
                var marker = new GMarker(point, markerOptions);
                GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml("<b>"+address+"</b>");
                });
                return marker;
            }
            function showAddress()
            {
                var address1='{!Account.BillingCity}'+'|'+'{!Account.ShippingCity}';
                var address=address1.split('|');
                for(var i=0;i<address.length;i++)
                {
                    if(address[i] == ''){continue;}
                    var addPart = address[i];
                    //alert("addM('" + addPart[0] + "','" + addPart[1] + "');");
                    //setTimeout("addM('" + addPart + "');",300);
                    addM(addPart);
                }
            }

            function addM(add)
            {
                add = add + ",India";
                if (geocoder)
                {
                    geocoder.getLatLng(add,function(point)
                        {
                            if (!point)
                            {
                                alert(add + " not found");
                            }
                            else
                            {                             
                                map.addOverlay(createMarker(point,add));                            
                            }
                        }
                    );                  
                }

            }
</script>
      
  <apex:form >   
      <div id="map_canvas" style="width: 989px; height: 250px"></div>
      <input type="button" value = "Show Markers" onClick="showAddress();"/>     
  </apex:form>
  <script type="text/javascript">
      initialize();
  </script>     
</apex:page>

Lets say your page name is multipleAddress your url looks like /apex/multipleAddress?id=accountId
Thanks

43 comments:

  1. Thanks Vijay , it is very helpful code.

    ReplyDelete
  2. Hi,

    no doubt this is great post but i have to pass accountId in url ... i want all address of account in this map means a VF page will open with all account address.

    ReplyDelete
  3. Thanks admin, for sharing your valuable post about cloud computing.
    cloud computing Training in Chennai

    ReplyDelete
  4. Hadoop Training Chennai

    Hi, I am Jack lives in Chennai. I am technology freak. I did Hadoop Training in Chennai at FITA which offers best Big Data Training in Chennai. This is useful for me to make a bright career in IT field.

    Big Data Training Chennai

    ReplyDelete
  5. I have read your post, it was good to read & i am getting some useful info's through your blog keep sharing...Salesforce is a new technology which helps you to get your career destination. Learn salesforce from corporate professionals with very good experience in Salesforce CRM.
    Salesforce training in Chennai | Salesforce course in Chennai

    ReplyDelete
  6. The information you have given here is truly helpful to me. CCNA- It’s a certification program based on routing & switching for starting level network engineers that helps improve your investment in knowledge of networking & increase the value of employer’s network, if you want to take ccna course in Chennai get into FITA, thanks for sharing…
    ccna training in Chennai | ccna training institute in Chennai | ccna course in Velachery

    ReplyDelete
  7. Your blog is really awesome and I got some useful information from your blog. This is really useful for me. Thanks for sharing such a informative blog. Keep posting.

    Regards..
    Cloud Computing Training Centers in Chennai

    ReplyDelete
  8. Thanks for sharing your innovative ideas..Its really useful and interesting...

    Regards...

    Salesforce CRM Training in Chennai

    ReplyDelete
  9. Hi friends, This is Murali from Chennai. I am a technology freak. Your technical information is really useful for me. Keep update your blog.
    Regards..
    Oracle Training Chennai

    ReplyDelete
  10. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog. Recently I did Software Testing Course in Chennai at a reputed training institutes.

    ReplyDelete
  11. Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers. Salesforce Training Institutes in Chennai | Salesforce Training in Chennai

    ReplyDelete
  12. Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers. Salesforce Training Institutes in Chennai | Salesforce Training in Chennai

    ReplyDelete
  13. Thanks for sharing this information. Java is one of the popular object oriented programming language used for many of the multinational corporation. So learning Java Course in Chennai is really helpful to make a bright future.

    ReplyDelete
  14. There are lots of information about latest technology and how to get trained in them, like Hadoop Training Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies(Hadoop Training in Chennai). By the way you are running a great blog. Thanks for sharing this.

    ReplyDelete
  15. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

    ReplyDelete
  16. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    Websphere Training in Chennai

    ReplyDelete
  17. Data warehousing Training in Chennai
    I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

    ReplyDelete
  18. Selenium Training in Chennai
    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    ReplyDelete
  19. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

    ReplyDelete
  20. SAP Training in Chennai
    This post is really nice and informative. The explanation given is really comprehensive and informative..

    ReplyDelete
  21. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Android Training In Chennai In Chennai

    ReplyDelete
  22. Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
    Unix Training In Chennai

    ReplyDelete
  23. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    SalesForce Training in Chennai

    ReplyDelete
  24. There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

    ReplyDelete
  25. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone. Visit us:
    Oracle Training in Chennai

    ReplyDelete
  26. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Oracle DBA Training in Chennai

    ReplyDelete
  27. great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
    Oracle RAC Training in Chennai

    ReplyDelete
  28. Wonderful tips, very helpful well explained. Your post is definitely incredible. I will refer this to my friend.
    SalesForce Training in Chennai

    ReplyDelete
  29. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Java Training in Chennai

    ReplyDelete
  30. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    PHP Training in Chennai

    ReplyDelete
  31. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me..
    Android Training in Chennai

    ReplyDelete
  32. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    SAP Training in Chennai

    ReplyDelete
  33. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Hadoop Training in Chennai

    ReplyDelete
  34. It is really very helpful for us and I have gathered some important information from this blog.If anyone wants to Selenium Training in Chennai reach Greens Technology training and placement academy.
    selenium Training in Chennai

    ReplyDelete
  35. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Informatica Training in chennai | QTP Training in Chennai



    ReplyDelete
  36. your providing such a valuabe information about studying..and also have some good key points to every student. SalesForce Videos

    ReplyDelete
  37. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

    ReplyDelete
  38. Best SQL Query Tuning Training Center In ChennaiIt’s too informative blog and I am getting conglomerations of info’s about Oracle interview questions and answer .Thanks for sharing, I would like to see your updates regularly so keep blogging.

    ReplyDelete


  39. interesting blog. It would be great if you can provide more details about it. Thanks you

    Function Point Estimation Training in Chennai

    ReplyDelete
  40. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Installment Loans Near Me
    Title loans Near Me
    Cash Advances Near Me

    ReplyDelete