【发布时间】:2014-02-15 03:47:00
【问题描述】:
在生成谷歌地图时,我将地址发送到 java 脚本函数。示例代码:--
java脚本功能代码:--
function codeAddress(address) {
// var address = document.getElementById("address").value;
var address;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
`" cs 代码:-- "
string addrs= "New York,USA";
Page.ClientScript.RegisterStartupScript(this.GetType(), "a", "codeAddress(" + addrs + ");", true);
" 我正在使用正确的 API 密钥和 url。在 html 中它的工作。但是当我从cs文件传递地址时它不起作用。为什么?我如何通过传递地址值来执行上面的java脚本函数..代码有什么问题...谢谢
【问题讨论】:
-
codeAddress 不接受任何参数,但您在代码隐藏中传递了一个参数。
-
我更新了我的代码,请检查
-
How to call google geocode service from c# code 的可能重复项(发现谷歌搜索“google map geocode c#” ...)
-
@Alex,你不觉得他的问题和 ASP.NET Web Forms 有关吗?
-
在你的第一行codeAddress放置一个console.log(),看看你是否正在输入你的函数。
标签: javascript asp.net google-maps