[英]Phonegap Cordova - cordova-plugin-googlemaps Plugin Search bar does nothing
I'm following this tutorial: https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Map 我正在关注本教程: https : //github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Map
I have added the searchBox HTML but the search box doesn't do anything. 我已经添加了searchBox HTML,但是搜索框没有任何作用。 I'm able to type in it though. 我可以输入。 Am I missing something? 我想念什么吗? I've read the entire thing from the start multiple times. 我已经从头开始阅读了整整本书多次。
Map loads fine and I'm able to navigate by scrolling. 地图加载正常,我可以通过滚动进行导航。
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 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){
}
you following part should be change: 您以下部分应更改:
function onMapReady() {
var button = document.getElementById("button");
button.addEventListener("click", onBtnClicked, false);
}
to 至
function onMapReady() {
var button = document.getElementById("searchBtn");
button.addEventListener("click", onBtnClicked, false);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.