Java 通过在文本框中提供纬度和经度,在网页内显示地图

Java 通过在文本框中提供纬度和经度,在网页内显示地图,java,javascript,html,google-maps,Java,Javascript,Html,Google Maps,我试过这个 这里的脚本 var locationmap=10.521649, 76.215076"; var map; var geocoder; function InitializeMap() { var input = document.getElementById('locationmap'), locationmap = input.value; alert("locationmap"+locationmap);

我试过这个

这里的脚本

var locationmap=10.521649, 76.215076";
var map;
    var geocoder; 
    function InitializeMap() {
        var input = document.getElementById('locationmap'),
        locationmap = input.value;
     alert("locationmap"+locationmap);
        var latlng = new google.maps.LatLng(locationmap);
        var myOptions =
        {
            zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true
        };
        map = new google.maps.Map(document.getElementById("map"), myOptions);
    }

    function FindLocaiton() {
        geocoder = new google.maps.Geocoder();
        InitializeMap();

        var address = document.getElementById("addressinput").value;
        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });

            }
            else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });

    } 
 window.onload = InitializeMap; 
html代码是

<div id="wb_Text8" style="position:absolute;left:34px;top:518px;width:97px;height:16px;z-index:18;text-align:left;">
                    <span style="color:#000000;font-family:Arial;font-size:13px;">Location Map :</span>
                </div>
                <input type="text" th:field="*{location_Map}" id="locationmap" style="position:absolute;left:157px;top:511px;width:193px;height:23px;line-height:23px;z-index:20;" name="Editbox3" value="" />
                <div id="map" style="height: 253px">
                </div>

位置图:
在这里网页加载第一次显示正确的地图。但是当我在文本框中更改lat&lon时,地图就不是chagne了

如果您知道这一点,请在此处分享。

如何调用
FindLocaiton()
以及为什么它内部有
InitializeMap()
?可能重复