Die Codekopie lautet wie folgt:
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<title> Abfragetastgrad und Längengrad basierend auf der Adresse </title>
<meta http-äquiv = "content-type" content = "text/html; charset = utf-8">
<script type = "text/javascript" src = "http://api.map.baidu.com/api?v=1.3"> </script>
</head>
<body style = "Hintergrund:#cbe1ff">
<div>
Die zu befragte Adresse: <Eingabe id = "text_" type = "text" value = "xuzhou gupeng square" style = "margin-reight: 100px;"/>
Abfrageergebnis (Breitengrad und Längengrad): <Eingabe -ID = "result_" type = "text" />
<input type = "button" value = "query" onclick = "SearchByStationName ();"/>
<div id = "Container"
style = "Position: absolut;
Randtop: 30px;
Breite: 730px;
Höhe: 590px;
Top: 50;
Grenze: 1px Festgrau;
Überlauf: versteckt; ">
</div>
</div>
</body>
<script type = "text/javaScript">
var map = new bmap.map ("Container");
MAP.CenterAnzoom ("Xuzhou", 12);
map.EnablesCrollwheelzoom (); // SCROLL Rad Zoom ein- und aus aktivieren, standardmäßig deaktiviert
map.enableContinuousZoom (); // MAP -Trägheitswiderstand und Drop aktivieren, standardmäßig deaktiviert
map.addControl (neue bmap.navigationControl ()); // Standard -Zoom -Pan -Steuerung hinzufügen
map.addControl (neue BMAP.OverviewMapControl ()); // Fügen Sie die standardmäßige Miniaturansichtskarte hinzu
map.addControl (neuer bmap.overviewMapControl ({isopen: true, Anchor: bmap_anchor_bottom_right})); // die untere rechte Ecke, geöffnet
var localSearch = new bmap.localsearch (MAP);
localSearch.enableAutoviewport (); // ermöglicht die automatische Einstellung der Formulargröße
Funktions SearchByStationName () {
map.clearoverlays (); // das Original -Tag löschen
var keyword = document.getElementById ("text _"). Wert;
localSearch.setsearchCompleteCallback (Funktion (SearchResult) {
var poi = searchResult.getPoi (0);
document.getElementById ("Ergebnis _"). Value = poi.point.lng + "," + poi.point.lat;
MAP.CenterAnzoom (Poi.Point, 13);
var marker = neuer BMAP.Marker (neuer BMAP.Point (poi.point.lng, poi.point.lat)); // Annotation erstellen, um den entsprechenden Breitengrad und Längengrad des abfragenden Ortes zu sein
map.adDoverlay (Marker);
var content = document.getElementById ("Text _"). Wert + "<br/> <br/> lang:" + poi.point.lng + "<br/> lat:" + poi.point.lat;
var infowindow = new bmap.infowindow ("<p style = 'Schriftgröße: 14px;'>" + Inhalt + "</p>");
marker.addeventListener ("click", function () {this.openInfowindow (infowindow);});
// marker.setanimation (bmap_animation_bounce); // Animation schlagen
});
localSearch.Search (Schlüsselwort);
}
</script>
</html>
Das obige ist der gesamte Code. Freunde können es direkt im Projekt verwenden. Sag nicht bei mir, bitte nenn mich Lei Feng ~