我正在关注本教程: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){
}
答案 0 :(得分:0)
你应该改变以下部分:
function onMapReady() {
var button = document.getElementById("button");
button.addEventListener("click", onBtnClicked, false);
}
以强>
function onMapReady() {
var button = document.getElementById("searchBtn");
button.addEventListener("click", onBtnClicked, false);
}