[英]Phonegap Cordova - cordova-plugin-googlemaps Plugin Search bar does nothing
我正在關注本教程: https : //github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Map
我已經添加了searchBox HTML,但是搜索框沒有任何作用。 我可以輸入。 我想念什么嗎? 我已經從頭開始閱讀了整整本書多次。
地圖加載正常,我可以通過滾動進行導航。
的HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
var map;
document.addEventListener("deviceready", function() {
var div = document.getElementById("map_canvas");
// Initialize the map view
map = plugin.google.maps.Map.getMap(div);
// Wait until the map is ready status.
map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
}, false);
function onMapReady() {
var button = document.getElementById("button");
button.addEventListener("click", onBtnClicked, false);
}
function onBtnClicked() {
map.showDialog();
}
</script>
<h3>PhoneGap-GoogleMaps-Plugin</h3>
<div style="width:100%;height:400px" id="map_canvas">
//SEARCH BOX CODE WHICH DOESN'T WORK
<div id="searchBox">
<input type="text" id="query" size="30" />
<button id="searchBtn">Search</button>
</div>
</div>
<button id="button">Full Screen</button>
JAVASCRIPT
document.addEventListener("deviceready", function() {
// Define a div tag with id="map_canvas"
var mapDiv = document.getElementById("map_canvas");
// Initialize the map plugin
var map = plugin.google.maps.Map.getMap(mapDiv);
// You have to wait the MAP_READY event.
map.on(plugin.google.maps.event.MAP_READY, onMapInit);
});
function onMapInit(map){
}
您以下部分應更改:
function onMapReady() {
var button = document.getElementById("button");
button.addEventListener("click", onBtnClicked, false);
}
至
function onMapReady() {
var button = document.getElementById("searchBtn");
button.addEventListener("click", onBtnClicked, false);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.