如何从数据库获取地址然后在前台调用百度地图将位置显示

JavaScript028

如何从数据库获取地址然后在前台调用百度地图将位置显示,第1张

数据库存经纬度坐标及文字描述,用ajax取出展示。

var map = new BMap.Map("container")

$(function()

{

$.getJSON("/map/ajaxDb.aspx?id="+$("#hid_id").val(), { "resultType": "json" }, function(data, textStatus)

{

slng=data[0].lng

slat=data[0].Lat

var sContent ="<div style='line-height:1.8emfont-size:12px'><b>地址:</b>"+data[0].address+"<br/></div>"

var marker = new BMap.Marker(new BMap.Point(slng, slat)) // 创建标注

map.addOverlay(marker) // 将标注添加到地图中

var infoWindow = new BMap.InfoWindow(sContent) // 创建信息窗口对象

marker.addEventListener("click", function(){

this.openInfoWindow(infoWindow)

})

})

})

你想实现www.woxiangyougejia.com 这上面的具体什么功能呢?

这是两个代码,其实就是Google maps 的examples中的

根据这两个就可以实现你要的功能

有什么不明白的参照Google maps api吧

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w2.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/htmlcharset=utf-8"/>

<title>Google Maps API Example - Google North America Offices</title>

<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxQcTQoRJ_JVFHVwderj38GcfiXt6hQX5E6h3W3sV-l-QbtgIls1pN0iAw"

type="text/javascript"></script>

<script src="google_northamerica_offices.js" type="text/javascript"></script>

<script src="../src/markermanager.js"></script>

<script type="text/javascript">

//<![CDATA[

var map

var mgr

var icons = {}

var allmarkers = []

function load() {

if (GBrowserIsCompatible()) {

map = new GMap2(document.getElementById("map"))

map.addControl(new GLargeMapControl())

map.addControl(new GOverviewMapControl())

map.setCenter(new GLatLng(50, -98), 3)

map.enableDoubleClickZoom()

mgr = new MarkerManager(map, {trackMarkers:true})

window.setTimeout(setupOfficeMarkers, 0)

}

}

function getIcon(images) {

var icon = null

if (images) {

if (icons[images[0]]) {

icon = icons[images[0]]

} else {

icon = new GIcon()

icon.image = "images/"

+ images[0] + ".png"

var size = iconData[images[0]]

icon.iconSize = new GSize(size.width, size.height)

icon.iconAnchor = new GPoint(size.width >>1, size.height >>1)

icon.shadow = "images/"

+ images[1] + ".png"

size = iconData[images[1]]

icon.shadowSize = new GSize(size.width, size.height)

icons[images[0]] = icon

}

}

return icon

}

function setupOfficeMarkers() {

allmarkers.length = 0

for (var i in officeLayer) {

var layer = officeLayer[i]

var markers = []

for (var j in layer["places"]) {

var place = layer["places"][j]

var icon = getIcon(place["icon"])

var title = place["name"]

var posn = new GLatLng(place["posn"][0], place["posn"][1])

var marker = createMarker(posn,title,icon)

markers.push(marker)

allmarkers.push(marker)

}

mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1])

}

mgr.refresh()

}

function createMarker(posn, title, icon) {

var marker = new GMarker(posn, {title: title, icon: icon, draggable:true })

GEvent.addListener(marker, 'dblclick', function() { mgr.removeMarker(marker) } )

return marker

}

function deleteMarker() {

var markerNum = parseInt(document.getElementById("markerNum").value)

mgr.removeMarker(allmarkers[markerNum])

}

function clearMarkers() {

mgr.clearMarkers()

}

function reloadMarkers() {

setupOfficeMarkers()

}

//]]>

</script>

</head>

<body onload="load()" onunload="GUnload()">

<input type="button" onclick="deleteMarker()" value="delete marker #:" />

 

<input type="text" id="markerNum" value="0" size="3"/>

|

<input type="button" onclick="clearMarkers()" value="clear all markers" />

|

<input type="button" onclick="reloadMarkers()" value="reload all markers" />

<br/>

<div id="map" style="width: 600pxheight: 400px"></div>

</body>

</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">

<head>

<meta http-equiv="content-type" content="text/htmlcharset=utf-8"/>

<title>Google Maps JavaScript API Example: Advanced Directions</title>

<script src=" http://maps.google.com/?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"

type="text/javascript"></script>

<style type="text/css">

body {

font-family: Verdana, Arial, sans serif

font-size: 11px

margin: 2px

}

table.directions th {

background-color:#EEEEEE

}

img {

color: #000000

}

</style>

<script type="text/javascript">

var map

var gdir

var geocoder = null

var addressMarker

function initialize() {

if (GBrowserIsCompatible()) {

map = new GMap2(document.getElementById("map_canvas"))

gdir = new GDirections(map, document.getElementById("directions"))

GEvent.addListener(gdir, "load", onGDirectionsLoad)

GEvent.addListener(gdir, "error", handleErrors)

setDirections("San Francisco", "Mountain View", "en_US")

}

}

function setDirections(fromAddress, toAddress, locale) {

gdir.load("from: " + fromAddress + " to: " + toAddress,

{ "locale": locale })

}

function handleErrors(){

if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)

alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code)

else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)

alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code)

else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)

alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code)

// else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong

// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code)

else if (gdir.getStatus().code == G_GEO_BAD_KEY)

alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code)

else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)

alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code)

else alert("An unknown error occurred.")

}

function onGDirectionsLoad(){

// Use this function to access information about the latest load()

// results.

// e.g.

// document.getElementById("getStatus").innerHTML = gdir.getStatus().code

// and yada yada yada...

}

</script>

</head>

<body onload="initialize()" onunload="GUnload()">

<h2>Maps API Directions Illustrated</h2>

<form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value)return false">

<table>

<tr><th align="right">From: </th>

<td><input type="text" size="25" id="fromAddress" name="from"

value="San Francisco"/></td>

<th align="right">  To: </th>

<td align="right"><input type="text" size="25" id="toAddress" name="to"

value="Mountain View" /></td></tr>

<tr><th>Language: </th>

<td colspan="3"><select id="locale" name="locale">

<option value="en" selected>English</option>

<option value="fr">French</option>

<option value="de">German</option>

<option value="ja">Japanese</option>

<option value="es">Spanish</option>

</select>

<input name="submit" type="submit" value="Get Directions!" />

</td></tr>

</table>

</form>

<br/>

<table class="directions">

<tr><th>Formatted Directions</th><th>Map</th></tr>

<tr>

<td valign="top"><div id="directions" style="width: 275px"></div></td>

<td valign="top"><div id="map_canvas" style="width: 310pxheight: 400px"></div></td>

</tr>

</table>

</body>

</html>

个人房产信息是不能在网上查询到的。

根据《不动产登记暂行条例实施细则》第九十七条国家实行不动产登记资料依法查询制度规定:

1、权利人、利害关系人按照规定依法查询、复制不动产登记资料的,应当到具体办理不动产登记的不动产登记机构申请。

2、权利人可以查询、复制其不动产登记资料。

3、因不动产交易、继承、诉讼等涉及的利害关系人可以查询、复制不动产自然状况、权利人及其不动产查封、抵押、预告登记、异议登记等状况。

4、人民法院、人民检察院、国家安全机关、监察机关等可以依法查询、复制与调查和处理事项有关的不动产登记资料。

5、其他有关国家机关执行公务依法查询、复制不动产登记资料的,依照本条规定办理。

6、涉及国家秘密的不动产登记资料的查询,按照保守国家秘密法的有关规定执行。

权利人、利害关系人按照规定依法查询、复制不动产登记资料的,应当到具体办理不动产登记的不动产登记机构申请。因为牵扯个人财产的安全和隐私,所以个人房产信息的查询不能在网络进行,只能在当地的房管部门查询。

扩展资料

个人房产信息查询方式具体如下:

1、查询房产信息可直接去房产局查询,若要查询准确的个人房产证信息,则必须携带个人身份证件及房产证到当地的房管局(房地产交易、房屋管理局、房管处)档案馆或者窗口查询。

2、房屋所有权人可以带着自己的身份证明,到房管部门房产档案科查询,因房权证的新旧交换,有些老房权证需要查询原始登记卷宗档案才可以查到。    

3、房屋所有权人可以带着自己的身份证明,到房管部门抵押登记科查询,若是已经办理贷款抵押登记(包括按揭贷款、抵押贷款等)的房产必须在这里办理抵押登记。

注:房产信息具有保密性,依据法律规定,当事人只有自己或委托他人(办理公证委托书)才可以查询自己名下的房产信息,除法律规定外其他人不得查询。