我用过微软地图,也许对你有帮助: 地图标记定位在某一点 VitualEarth.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.1"></script> <script type="text/javascript"> var map = null; var LA = new VELatLong(43.815887948922544, 87.5988006591797); var pinPoint = null; var pinPixel = null;
function GetMap() { map = new VEMap('myMap'); map.LoadMap(LA, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1); AddPin(); } function AddPin() { // Add a new pushpin to the center of the map. pinPoint = map.GetCenter(); pinPixel = map.LatLongToPixel(pinPoint); map.AddPushpin(pinPoint); } </script> </head> <body onload="GetMap();"> <div id='myMap' style="position:relative; width:400px; height:400px;"></div> </body> </html> 鼠标点击定位坐标点: VitualEarth_GetPoint.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> body { font-size:12px; } </style> <script type="text/javascript" src="http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.1"></script> <script type="text/javascript"> var map = null; var pixel = null; var clickEvent = null;
function GetMap() { map = new VEMap('myMap'); map.LoadMap(); map.AttachEvent("onclick", PixelClick); }
function PixelClick(e) { var x = e.mapX; var y = e.mapY; pixel = new VEPixel(x, y); var LL = map.PixelToLatLong(pixel); info.innerHTML = "Pixel X: " + x + " | Pixel Y: " + y + "<br /> LatLong: " + LL; returnVal.innerText = LL; } </script> </head> <body onload="GetMap();" style="font-family:Arial"> <div id='myMap' style="position:relative; width:400px; height:400px;"></div> <div id="mapInfo"> 在地图上单击选择地理位置,点<a href="#" onclick="opener.document.getElementById('ctl00$ContentPlaceHolder1$txt_mapinfo').value=document.getElementById('returnVal').innerText;window.close();">这里</a>返回父窗体.<br /> <span id="info"></span><div id="returnVal"></div> </div> </body> </html>
而通过AJAX Search API只能把结果显示到网页中,而无法在程序中获得。
那还有其它办法在程序中利用google搜索获得结果?我的应用中是要把每条搜索结果整理到数据库中,以备使用。
百度还提供基于webservice的search接口吗?
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Control Initialization</title>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[ function initialize() {
///////////////////**** 自定义控件 ****///////////////////////////
var crossLayer = new GTileLayer(new GCopyrightCollection(""), 0, 15);
crossLayer.getTileUrl = function(tile, zoom) {
return "./include/tile_crosshairs.png";
}
crossLayer.isPng = function() {return true;} // 创建一个新的地图类型纳入瓦层
var layerTerCross = [ G_PHYSICAL_MAP.getTileLayers()[0],
crossLayer ];
var mtTerCross = new GMapType(layerTerCross,
G_PHYSICAL_MAP.getProjection(), "Ter+"); var map = new GMap2(document.getElementById("map_canvas"),
{ size: new GSize(640,320) } );
map.addMapType(G_PHYSICAL_MAP);
map.addMapType(mtTerCross);
map.setCenter(new GLatLng(39.917,116.397), 8);
map.addControl(new GLargeMapControl()) var mapControl = new GHierarchicalMapTypeControl();
// 地图类型设置菜单中关系
mapControl.clearRelationships();
mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
mapControl.addRelationship(G_PHYSICAL_MAP, mtTerCross, "Crosshairs");
// 添加控制后,您所指定的关系
map.addControl(mapControl);
///////////////////**** 自定义控件 ****///////////////////////////
// 加载双击事件(提示GPoint与缩放级别)
if (GBrowserIsCompatible()) {
GEvent.addListener(map,"click", function(overlay,latlng) {
var myHtml = "GPoint 为: " + map.fromLatLngToDivPixel(latlng) + ",<br>缩放级别为:" + map.getZoom();
map.openInfoWindow(latlng, myHtml);
});
}
}
//]]>
</script>
</head> <body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 640px; height: 320px"></div>
</body>
</html>
你说的代码我在zendfreamwork框架的Demo中看到过的 不难 就是用Ajax完成于Yahoo和Google的数据交互
甚至不需要写PHP代码 数据可以与远程的xml wsdl缓存交互 也可以直接调用Yahoo的收索API 据我所知Google和baidu目前不开放API Google是部分开放 百度不开放 Yahoo100%开放
用它传递参数并接收到GOOGLE返回的结果,把它当作一个大字串,进行搜索定位提取。就那些字串操作函数,不用多说吧。
地图标记定位在某一点
VitualEarth.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.1"></script> <script type="text/javascript">
var map = null; var LA = new VELatLong(43.815887948922544, 87.5988006591797); var pinPoint = null;
var pinPixel = null;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(LA, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1); AddPin();
} function AddPin()
{
// Add a new pushpin to the center of the map.
pinPoint = map.GetCenter();
pinPixel = map.LatLongToPixel(pinPoint);
map.AddPushpin(pinPoint);
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>
鼠标点击定位坐标点:
VitualEarth_GetPoint.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body
{
font-size:12px;
}
</style>
<script type="text/javascript" src="http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.1"></script>
<script type="text/javascript">
var map = null;
var pixel = null;
var clickEvent = null;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
map.AttachEvent("onclick", PixelClick);
}
function PixelClick(e)
{
var x = e.mapX;
var y = e.mapY;
pixel = new VEPixel(x, y);
var LL = map.PixelToLatLong(pixel);
info.innerHTML = "Pixel X: " + x + " | Pixel Y: " + y + "<br /> LatLong: " + LL;
returnVal.innerText = LL;
}
</script>
</head>
<body onload="GetMap();" style="font-family:Arial">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<div id="mapInfo">
在地图上单击选择地理位置,点<a href="#" onclick="opener.document.getElementById('ctl00$ContentPlaceHolder1$txt_mapinfo').value=document.getElementById('returnVal').innerText;window.close();">这里</a>返回父窗体.<br />
<span id="info"></span><div id="returnVal"></div>
</div>
</body>
</html>
如果baidu或者google的API不提供纯搜索结果返回,也只能用这个笨办法。
但是我用的是一个网上开源的类和openflashchart!