本文介绍了CS0103:当前上下文中不存在名称“ConvertDataTabletoString”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我试图使用下面的代码,但显示上面这个问题。请帮我找出解决方案。在页面加载时,我添加了一个方法名称,即ConvertDataTabletoString( )和iam试图调用方法...这个代码我从下面的链接中获取



[]

var markers = JSON.parse('<%= ConvertDataTabletoString()%>'); \\在这里错误



< script type =text / javascript>

函数initialize(){

var markers = JSON.parse(' <%= ConvertDataTabletoString()%>'); \\错误在这里

var mapOptions = {

center:new google.maps.LatLng(markers [0] .lat,markers [0] .lng),

zoom:5,

mapTypeId:google.maps。 MapTypeId.ROADMAP

// marker:true

};

var infoWindow = new google.maps.InfoWindow();

var map = new google.maps.Map(document.getElementById(map_canvas),mapOptions);

for(i = 0;我< markers.length; i ++){

var data = markers [i]

var myLatlng = new google.maps.LatLng(data.lat,data.lng);

var marker = new google.maps.Marker({

position:myLatlng,

map:map,

title:data。标题

});

(函数(标记,数据){



//附加点击事件到当前标记

google.maps.event.addListener(marker,click,function(e){

infoWindow.setContent(data.description);

infoWindow.open(地图,标记);

});

})(标记,数据);

}

}

google.setOnLoadCallback(initialize);

< / script>

hi all,
Iam trying to use below code but showing this above problem.Please,help me to find out the solution.On page load,I have added a method name that is ConvertDataTabletoString() and iam trying to call the method...This code I have taken from below links

http://www.aspdotnet-suresh.com/2013/05/aspnet-show-multiple-markers-on-google.html[^]
var markers = JSON.parse('<%=ConvertDataTabletoString() %>');\\ error here

<script type="text/javascript">
function initialize() {
var markers = JSON.parse('<%=ConvertDataTabletoString() %>');\\ error here
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
// marker:true
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {

// Attaching a click event to the current marker
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
google.setOnLoadCallback(initialize);
</script>

推荐答案

这篇关于CS0103:当前上下文中不存在名称“ConvertDataTabletoString”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 04:15