[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 jQuery.Class("MapView",{ 10 11 url:"index.php?module=Google&action=MapAjax&mode=getLocation", 12 13 /** 14 * function to make api request to google maps. 15 * On completion display the image 16 */ 17 showMap:function(){ 18 var record=jQuery('#map_record').html(); 19 var module=jQuery('#map_module').html(); 20 MapView.url+='&recordid='+record+'&source_module='+module; 21 jQuery.ajax({ 22 url:MapView.url 23 }).done(function(res){ 24 var result=JSON.parse(res); 25 var address=result["address"]; 26 var map_url=MapView.getStaticMapURL(address,"250x250"); 27 var location=jQuery.trim((address).replace(/\,/g," ")); 28 if(location != '' && location!=null){ 29 jQuery("#map_address").html(location); 30 jQuery('#map_address').show(); 31 } 32 jQuery("#map_canvas").append("<img id='map_image'></img>"); 33 jQuery("#map_image").attr("src",map_url); 34 jQuery("#map_image").addClass('cursorPointer'); 35 jQuery("#map_image").on('click',function(){ 36 window.open(MapView.getQueryString(address,'_parent')); 37 }); 38 jQuery("#map_link").on('click',function(){ 39 window.open(MapView.getQueryString(address,'_parent')); 40 }); 41 }); 42 }, 43 /** 44 * get the googleapis url based on the address and the size of the image. 45 */ 46 getStaticMapURL : function (address,size){ 47 var encoded_address=encodeURIComponent(address); 48 var url=" http://maps.googleapis.com/maps/api/staticmap?size="+size+"&maptype=roadmap&markers=size:mid%7Ccolor:red%7C"+encoded_address+"&sensor=false"; 49 return url; 50 } , 51 52 getQueryString:function (address){ 53 address=address.replace(/ /g,'+'); 54 return "http://maps.google.com/maps?q="+address+"&zoom=14&size=512x512&maptype=roadmap&sensor=false"; 55 } 56 57 },{}); 58 59 jQuery(document).ready(function(){ 60 MapView.showMap(); 61 }); 62 63
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |