本文介绍了如何在数组中保存地理编码结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Geocoder请求生成的结果存储在全局数组中?比方说,我传递一个包含地址的数组,我想将LatLng结果存储在地理编码函数之外的新全局数组中?

Is it possible to store the results produced by Geocoder request in a global array? Let's say, I pass an array containing addresses, and I want LatLng results to be stored in a new global array outside the geocode function?

推荐答案

<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
        var latLong = [];
        var count = 0;

        function getLatLong(){







如果您将运行上述代码,结果将输出为=>



latLong [0] ['lat'] = 19.2898089

latLong [0] ['lng'] = 84.87185109999996

latLong [1] ['lat'] = 19.2947663

latLong [2] ['lng'] = 84.81182179999996



希望这个会帮助你:)。



If you will run the above code, the result will output as =>

latLong[0]['lat'] = 19.2898089
latLong[0]['lng'] = 84.87185109999996
latLong[1]['lat'] = 19.2947663
latLong[2]['lng'] = 84.81182179999996

Hope this will help you :).


这篇关于如何在数组中保存地理编码结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 17:42