google maps - anchor tag not working in Desktop or Salesforce1 -
i displaying marker every near account , below anchor tag should navigate respective account upon clicking it.i have used code in workbook,but works neither in desktop nor in salesforce1.i have checked posts users reported redirection happening wrong page.but in case page refreshes , stays on same page.please help
try{ if(sforce.one){ accountnavurl = 'javascript:sforce.one.navigatetosobject(\'' + account.id + '\')'; } } catch(err) { console.log(err); var did=account.id; accountnavurl= '\\' + account.id; } console.log('-->'+accountnavurl ); var content='<a href src="'+accountnavurl +'" >'+account.name+ '</a><br/>'+account.billingstreet +'<br/>' + account.billingcity +'<br/>' + account.billingcountry;
below whole code
<apex:page standardcontroller="account" extensions="accountmapext" sidebar="false" showheader="false"> <!-- begin default content remove --> <apex:includescript value="https://maps.googleapis.com/maps/api/js?sensor=false" /> <style> html, body { height: 100%; } .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; } #map-canvas { height: min-height: 100%; } </style> <script> var lat; var lon; function initialize(){ if(navigator.geolocation){ navigator.geolocation.getcurrentposition( function(position){ lat=position.coords.latitude; lon=position.coords.longitude; visualforce.remoting.manager.invokeaction('{!$remoteaction.accountmapext.getnearby}',lat, lon, function(result, event){ if (event.status) { console.log('->'+lat+' '+lon+' '+result); createmap(lat, lon, result); } else if (event.type ==='exception') { //exception case code } else { } }, {escape: true} ); } ); } } function createmap(lat,lon,accounts){ console.log('calling map '+ lat+' '+lon); var currentposition = new google.maps.latlng(lat,lon); var mapdiv = document.getelementbyid('map-canvas'); var map = new google.maps.map(mapdiv, { center: currentposition, zoom: 13, maptypeid: google.maps.maptypeid.roadmap }); var positionmarker = new google.maps.marker({ map: map, position: currentposition, icon: 'https://maps.google.com/mapfiles/ms/micons/green.png' }); for(var i=0; i<accounts.length;i++){ account= accounts[i]; console.log(accounts[i]); setupmarker(); } function setupmarker(){ var accountnavurl; try{ if(sforce.one){ accountnavurl = 'javascript:sforce.one.navigatetosobject(\'' + account.id + '\')'; } } catch(err) { console.log(err); var did=account.id; accountnavurl= '\\' + account.id; } console.log('-->'+accountnavurl ); var content='<a href src="'+accountnavurl +'" >'+account.name+ '</a><br/>'+account.billingstreet +'<br/>' + account.billingcity +'<br/>' + account.billingcountry; //create callout pop on marker var infowindow = new google.maps.infowindow({content: content}); //place marker var marker = new google.maps.marker({ map: map, position: new google.maps.latlng(account.billinglatitude,account.billinglongitude)} ); google.maps.event.addlistener(marker, 'click', function(){ infowindow.open(map, marker); }); } var mapboundary = new google.maps.latlngbounds(); mapboundary.extend(currentposition); } google.maps.event.adddomlistener(window, 'load', initialize); </script> <body style="font-family: arial; border: 0 none;"> <div id="map-canvas"></div> </body> <!-- end default content remove --> </apex:page>
below code did trick!
var accountnavurl; try{ if(sforce.one){ accountnavurl='<a href="javascript:sforce.one.navigatetosobject(\''+account.id+'\');">'; } } catch(err) { console.log(err); accountnavurl='<a href="../' + account.id + '" target="_parent">'; } console.log('-->'+accountnavurl ); var content=accountnavurl+account.name+ '</a><br/>'+account.billingstreet +'<br/>' + account.billingcity +'<br/>' + account.billingcountry;
Comments
Post a Comment