如何在codeigniter中获取纬度和经度数据

时间:2017-03-02 13:48:15

标签: php codeigniter

如何在变量php.i中获取数据后将标记拖入视图class.iam需要纬度和经度。在alert()上获取正确的纬度和经度。

$纬度=? $经度=?

    //map
    $this->load->library('googlemaps');

    $config['center'] = '37.4419, -122.1419';
    $config['zoom'] = 'auto';
    $this->googlemaps->initialize($config);

    $marker = array();
    $marker['position'] = '37.429, -122.1419';
    $marker['draggable'] = true;

    //working alert on view and popup latitude and lontitude
    $marker['ondragend'] = 'alert(\'You just dropped me at: \' + event.latLng.lat() + \', \' + event.latLng.lng());';
    $this->googlemaps->add_marker($marker);
    $arr['latitude']=?

    //location need which is popup in alert() as event.latLng.lng()
    $arr['longitude']=?

1 个答案:

答案 0 :(得分:0)

//在javascript中试用

    function loadMap() 
    {
       var a=(document.getElementById("la").value);
       var b=(document.getElementById("lo").value); ;

       var mapOptions = {
          center:new google.maps.LatLng(a,b ),
          zoom:17
       }

       var map = new google.maps.Map(document.getElementById("your div id"),mapOptions);

       var marker = new google.maps.Marker({
          position: new google.maps.LatLng(a, b),
          map: map
       });
    }