锚标记在 Desktop 或 Salesforce1 中不起作用
anchor tag not working in Desktop or Salesforce1
我正在为每个附近的帐户显示标记,并且锚标记下方应该在单击后导航到相应的帐户it.I已经使用了工作簿中的代码,但它在桌面和 [=17= 中都不起作用] 已检查用户报告重定向发生错误的帖子 page.But 在我的案例中页面只是刷新并保持不变 page.Please 帮助
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;
下面是我的全部代码
<apex:page standardController="Account" extensions="AccountMapExt" sidebar="false" showHeader="false">
<!-- Begin Default Content REMOVE THIS -->
<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 the callout that will pop up on the marker
var infowindow = new google.maps.InfoWindow({content: content});
//Place the 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 THIS -->
</apex:page>
下面的代码成功了!
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;
我正在为每个附近的帐户显示标记,并且锚标记下方应该在单击后导航到相应的帐户it.I已经使用了工作簿中的代码,但它在桌面和 [=17= 中都不起作用] 已检查用户报告重定向发生错误的帖子 page.But 在我的案例中页面只是刷新并保持不变 page.Please 帮助
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;
下面是我的全部代码
<apex:page standardController="Account" extensions="AccountMapExt" sidebar="false" showHeader="false">
<!-- Begin Default Content REMOVE THIS -->
<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 the callout that will pop up on the marker
var infowindow = new google.maps.InfoWindow({content: content});
//Place the 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 THIS -->
</apex:page>
下面的代码成功了!
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;