google.maps.LocalSearch()只能在地图上加搜索框,能否把搜索框移到外面来?在页面上有3个html控件:
textbox button 及google的div
现在需要在textbox中输入信息(如:北京),点击button
然后google地图上即可显示北京的er.
textbox button 及google的div
现在需要在textbox中输入信息(如:北京),点击button
然后google地图上即可显示北京的er.
解决方案 »
- 求助,如何在.net中实现打印及打印预览
- asp.net实现文件夹遍历、文件大小统计等
- 多个cookies如果共存?急!!!!!!
- iis不能浏览aspx文件
- 怎么为body增加一下事件
- 高分寻找论坛源码下载地址
- 关于ActiveReport导出到excel的问题
- 如何用WebService返回的xml字符串来组装一个字符串(如何用javascript如何编写)
- 超难度问题 aspnet_wp.exe could not be started. The error code for the failure is 80070718
- windows验证问题,请大家帮忙
- 怎么用js在客户端判断textbox是否为空
- 请教如何做一个学校管理系统?
if(textbox.value=="北京") map.addOverlay(new GMarker(point));
搜索一下 Google Maps API 就可以啦
现在需要的是搜索google中的地点信息,类似LocalSearch()的功能,只是搜索框可以自己设置
"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/html; charset=UTF-8"/>
<title>Google Maps JavaScript API Example: Extraction of Geocoding Data</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"> var map;
var geocoder; function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(30.256695,120.17395,true), 14);
map.enableScrollWheelZoom();//滑轮缩放
var smallMapControl = new GSmallMapControl();
var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
map.addControl(smallMapControl, topRight);
geocoder = new GClientGeocoder();
} // addAddressToMap() is called when the geocoder returns an
// answer. It adds a er to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Place[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
map.setCenter(point,14);
// var optionss = new GMarkerOptions;
// optionss.title = 'here';
// optionss.icon = G_DEFAULT_ICON ;
er = new GMarker(point);
map.addOverlay(er);
er.openInfoWindowHtml(place.address + '<br>' + '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
GEvent.addListener(er,'click',function(){
er.openInfoWindowHtml(place.address + '<br>' + '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
});
}
} // showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a er to the map at that location.
function showLocation() {
var address = document.forms[0].q.value;
geocoder.getLocations(address, addAddressToMap);
} </script>
</head> <body onload="initialize()"> <!-- Creates a simple input box where you can enter an address
and a Search button that submits the form. //-->
<form action="#" onsubmit="showLocation(); return false;">
<p>
<b>Search for an address:</b>
<input type="text" name="q" value="" class="address_input" size="40" />
<input type="submit" name="find" value="Search" />
</p>
</form>
<div id="map_canvas" style="width: 1000px; height: 600px"></div>
</body>
</html>