【问题标题】:Reverse Geocoding in Oracle Apex (From draggable marker)Oracle Apex 中的反向地理编码(来自可拖动标记)
【发布时间】:2015-04-16 17:32:54
【问题描述】:

我目前允许用户将地址放入文本框并在 Google 地图上显示地址,但我现在想做相反的事情并获得与文本框最近的匹配地址(位于单独的区域,相同页)从一个可拖动的标记。我听说我应该使用 JSON 和 PHP 或 PL/JSON 将数据从地图获取到文本框。但是,我对 JSON 没有任何了解,我认为 Google 地图 API 在 JavaScript 中提供了这种地理编码方法。我不确定如何完全应用它,以及是否可以在一个页面中获取这两种方法(或者我应该使用一些带有 JavaScript 的过程并在页面上调用它,不确定)。到目前为止,这是我在页面的 HTML Header 中的代码:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

<script type="text/javascript">
var uniLatLng = new google.maps.LatLng (51.887496, -2.088788);
var geocoder = new google.maps.Geocoder();
var map;

function geocodePosition(pos) {
        geocoder.geocode({
                latLng: pos
        },
        function(responses) {
                if (responses && responses.length > 0) {
                        updateMarkerAddress(responses[0].formatted_address);
                }
                else {
                    updateMarkerAddress('Cannot determine address at this location.');
                }
        });
}

function updateMarkerStatus(str) {
        document.getElementById('P15_ADDRESS').value;
}

function initialize() {
        geocoder = new google.maps.Geocoder();
        var mapOptions = {
                zoom: 16,
                center: uniLatLng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
};

var marker = new google.maps.Marker({
            map: map,
            animation: google.maps.Animation.DROP,
            flat: false,
            position: new google.maps.LatLng(59.327383, 18.06747)
})

function map_canvas() {
        var address = "&P15_ADDRESS.";
        geocoder.geocode( { 'address': address, 'region': "GB"}, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                        map.setCenter(results[0].geometry.location);
                        var marker = new google.maps.Marker({
                                map: map,
                                draggable: true,
                                animation: google.maps.Animation.DROP,
                                flat: false,
                                position: results[0].geometry.location
                        });
                }
                else {
                        alert("Geocode was not successful for the following reason: " + status);
                }
        });
}
</script>

页面 HTML 正文属性 - onload="initialize(), map_canvas()"

有什么建议可以实现吗?

【问题讨论】:

    标签: javascript google-maps plsql oracle-apex reverse-geocoding


    【解决方案1】:

    我认为这个示例在反向地理编码部分可以满足您的需求。
    https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse

    您唯一需要添加的是带有on dragged 侦听器的可拖动标记,它将更新位置并调用与Reverse Geocode 按钮中相同的方法。

    【讨论】:

    • 是的,我同意,但是在 apex 中并不那么简单,我大致可以使用 html 和 JavaScript 来完成,但将值从 Google 地图传递到顶点区域的特定文本字段(P20_ADDRESS、P20_POST_CODE 等)需要更多。目前我正在执行将由(PL/SQL 和 JavaScript 位)调用的过程(SQL + JavaScript),以显示标记并将值传递给变量,变量将被转换为特定的文本字段(PL /SQL)。这是我的计划,看看它会如何运作;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-11
    • 2015-10-31
    相关资源
    最近更新 更多