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

52 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. Thanks for sharing your innovative ideas..Its really useful and interesting...

    Regards...

    Salesforce CRM Training in Chennai

    ReplyDelete
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. your providing such a valuabe information about studying..and also have some good key points to every student. SalesForce Videos

    ReplyDelete


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

    Function Point Estimation Training in Chennai

    ReplyDelete
  15. I found your post while searching for some related information on blog search... Its a great blog, keep posting and update the information.
    Selenium Training in Chennai
    software testing selenium training
    JAVA J2EE Training Institutes in Chennai
    JAVA Course
    iOS Training in Adyar
    iOS Course in Tambaram

    ReplyDelete
  16. Awwsome informative blog ,Very good information thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
    Aviation Academy in Chennai | Aviation Courses in Chennai | Best Aviation Academy in Chennai | Aviation Institute in Chennai | Aviation Training in Chennai

    ReplyDelete
  17. Great articles, first of all Thanks for writing such lovely Post!

    Article submission sites

    Education

    ReplyDelete
  18. Nice Article,Great experience for me by reading this info.
    thanks for sharing the information with us.keep updating your ideas.
    Android Training in chennai
    Android Training in T nagar
    Android Training in Anna Nagar
    android application development course in bangalore

    ReplyDelete
  19. I’ve desired to post about something similar to this on one of my blogs and this has given me an idea. Cool Mat.

    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  20. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Data Science training in rajaji nagar | Data Science Training in Bangalore
    Data Science with Python training in chennai
    Data Science training in electronic city
    Data Science training in USA
    Data science training in pune
    Data science training in kalyan nagar

    ReplyDelete

  21. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage
    contribution from other ones on this subject while our own child is truly discovering a great deal.
    Have fun with the remaining portion of the year.
    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  22. Thanks For Sharing The Information Please Keep Updating us Information Shared Is Very Valuable Time Just Went On Reading The Article Python Online Training AWS Online Training Data Science Online Training Data Science Online Training Hadoop Online Training

    ReplyDelete
  23. Thanks For Sharing The Information Please Keep Updating us Information Shared Is Very Valuable Time Just Went On Reading The Article Python Online Training AWS Online Training Data Science Online Training Data Science Online Training Hadoop Online Training

    ReplyDelete
  24. This comment has been removed by the author.

    ReplyDelete
  25. I can set up my new idea from this post. It gives in depth information. Thanks for this valuable information for all,..
    big data course malaysia

    ReplyDelete
  26. It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.
    data analytics course malaysia

    ReplyDelete
  27. Wonderful post. Thanks for taking time to share this information with us...
    Digital Marketing Courses in Bangalore

    ReplyDelete
  28. Nice blog. thanks for sharing valuable information. oracle training in chennai

    ReplyDelete
  29. Reach to the best Python Training institute in Chennai for skyrocketing your career, Infycle Technologies. It is the best Software Training & Placement institute in and around Chennai, that also gives the best placement training for personality tests, interview preparation, and mock interviews for leveling up the candidate's grades to a professional level.

    ReplyDelete
  30. Infycle Technologies, the No.1 software training institute in Chennai offers the best Big Data Hadoop training in Chennai for students, freshers and tech professionals. In addition to Big Data, Infycle also offers other professional courses such as Cyber Security ,Python, Oracle, Java, Power BI, Selenium Testing, Digital Marketing, Data Science, etc., which will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7502633633 to get more info and a free demo. Best Big Data Hadoop Training in Chennai | Infycle Technologies

    ReplyDelete
  31. Reach to the best <a href='https://infycletechnologies.com/python-training-in-chennai">Python Training institute in Chennai</a> for skyrocketing your career, Infycle Technologies. It is the best Software Training & Placement institute in and around Chennai, that also gives the best placement training for personality tests, interview preparation, and mock interviews for leveling up the candidate's grades to a professional level.

    ReplyDelete
  32. Very Informative blog thank you for sharing. Keep sharing.

    Best software training institute in Chennai. Make your career development the best by learning software courses.

    best rpa training in chennai
    best msbi training institute in chennai
    azure training in chennai
    power bi training in chennai

    ReplyDelete
  33. Infycle Technology, the finest Software Training Institutes in Chennai Offering technical courses like Big Data, Cyber Security, Artificial Intelligence, Oracle, Java, Hadoop, Selenium, Android, and iOS Development, Data Science etc. It is the Best place to take Big Data Training in Chennai for freshers, students, and tech professionals. For more enquiry and the free demo classes, Contact 7504633633.

    ReplyDelete
  34. I believe there are many more pleasurable opportunities ahead for
    individuals that looked at your site.
    oracle dba course in chennai
    java course in chennai
    node js training institute in chennai

    ReplyDelete
  35. Congratulations on your article, it was very helpful and successful. f1509f5bab2ee97c9bbbabe1e5dc2da6
    website kurma
    website kurma
    sms onay

    ReplyDelete
  36. Thank you for your explanation, very good content. 6f7ba0dde790585725e3c749a4222366
    altın dedektörü

    ReplyDelete
  37. Thanks for your article. 89ed547232bde96627aed3465f1a8ae6
    evde iş imkanı

    ReplyDelete