【问题标题】:Phonegap Cordova - cordova-plugin-googlemaps Plugin Search bar does nothingPhonegap Cordova - cordova-plugin-googlemaps 插件搜索栏什么都不做
【发布时间】: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){
}

程序的PrintScreen

【问题讨论】:

    标签: javascript html cordova maps


    【解决方案1】:

    你下面的部分应该改变:

    function onMapReady() {
      var button = document.getElementById("button");
      button.addEventListener("click", onBtnClicked, false);
    }
    

    function onMapReady() {
      var button = document.getElementById("searchBtn");
      button.addEventListener("click", onBtnClicked, false);
    }
    

    【讨论】:

      猜你喜欢
      • 2018-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      相关资源
      最近更新 更多