【发布时间】:2019-11-30 20:40:39
【问题描述】:
我试图从我的控制器的可拖动标记中获取 lat nad lng,
我的控制器功能
public function addnew(){
// Load the library
$this->load->library('googlemaps');
// Load our model
$this->load->model('Sedes_model', '', TRUE);
// Initialize the map, passing through any parameters
$config['center'] = '-17.3718, -66.1615';
$config['zoom'] = "15";
$this->googlemaps->initialize($config);
// Get the co-ordinates from the database using our model
$sedes = $this->Sedes_model->getCoordanites();
// Loop through the coordinates we obtained above and add them to the map
foreach ($sedes as $row) {
$marker = array();
$marker['position'] = $row->location;
$this->googlemaps->add_marker($marker);
}
$marker = array();
$marker['position'] = '-17.3718, -66.1615';
$marker['draggable'] = true;
$marker['ondragend'] = 'alert(\'You just dropped me at: \' + event.latLng.lat() + \', \' + event.latLng.lng());';
$this->googlemaps->add_marker($marker);
// Create the map
$data = array();
$data['map'] = $this->googlemaps->create_map();
print_r($data['map']['markers']);
// Load our view, passing through the map data
$this->load->view('sedes/add_sede_view', $data);
}
有了这个,我得到了我的地图,上面有我的数据库中的一些标记,还有一个可拖动的标记。
我试图从标记中获取 lat 和 lng 到我视图中的输入值,现在我在警报框中得到坐标。我想我必须为此使用 javascript,但我不太了解它
非常感谢您对此提供的任何帮助。
【问题讨论】:
标签: javascript php codeigniter