首页 新闻 会员 周边

Asp.Net 如何实现地图功能!

0
悬赏园豆:20 [待解决问题]

我想实现后台后台添加坐标,同时在前台显示地图!!!!请问有人能帮我实现吗?最好能给我一个实例源码!!!!我的邮箱:wshhicc@163.com

追梦浪子的主页 追梦浪子 | 初学一级 | 园豆:40
提问于:2010-12-24 15:13
< >
分享
所有回答(2)
0
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MapTest6.aspx.cs" Inherits="MapTest6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>V3 版本 根据地理名称定位</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder
= new google.maps.Geocoder();
var latlng
= new google.maps.LatLng(39.904667, 116.408198);
var myOptions
= {
zoom:
12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map
= new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

//获得地址并回传
function codeAddress() {
var address
= document.getElementById("address").value;
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(
"地理编码没有成功,原因如下: " + status);
}
});
}
</script>
</head>
<body onload="initialize()">
<div>
<input id="address" type="text" value="北京 方庄">

<input type="button" value="Geocode" onclick="codeAddress()">
</div>
<div id="map_canvas" style="height:90%"></div>
</body>
</html>

  这段代码是把 要查询的地址写在前台文本框的,你可以让文本框的值从后面传过来

dream梦false | 园豆:316 (菜鸟二级) | 2010-12-24 15:29
0

引用其他地图的API?51ditu的比较简单,记得两三句话就能引用到一个地图。

顾晓北 | 园豆:10844 (专家六级) | 2010-12-24 15:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册