【发布时间】:2016-08-11 00:26:52
【问题描述】:
我正在关注本教程: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){
}
【问题讨论】:
标签: javascript html cordova maps