我已经阅读了很多关于 geojson 的内容,但我想知道是否有其他方法。以下是我添加当前兴趣点的方法:
var map = L.map('map').setView([39.76, -98.5], 4);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
var marker = L.marker([33.1958, -117.3786]).addTo(map);
marker.bindPopup("<b>Trainers</b><br>Oceanside, CA.").openPopup();
var marker = L.marker([38.9125, -75.4283]).addTo(map);
marker.bindPopup("<b>Trainers</b><br>Milford, DE.").openPopup();
var marker = L.marker([41.26129, -95.93262]).addTo(map);
marker.bindPopup("<b>Trainers</b><br>Omaha, NE.").openPopup();
var marker = L.marker([25.77516, -80.2002]).addTo(map);
marker.bindPopup("<b>Trainers</b><br>Miami, FL.").openPopup();
//map.on('moveend', onMapMove);
//On mouse over will display the coordinates
map.on('mousemove', function (e) {
var latlng = e.latlng;
document.getElementById('latlong').innerHTML = latlng;},
this);
这是我的ajax:
$(document).ready(function(){
$.ajax({
type: 'POST',
dataType: "json",
url: '<?php echo matry::base_to('tests/map_it');?>',
success: function (data)
{
alert($.parseJSON(data[0]).id);
$('#alerts').html(data);
data[0].id
}
});
});
这是我的php:
$mapit = sql::results("Select * from event.ACS.trainer where inactive is null or inactive=0");
foreach ($mapit as $row)
{
$return[] = json_encode($row, JSON_FORCE_OBJECT);
}
echo json_encode($return);
我的 json 对象正在返回我需要的所有正确数据。我现在坚持在他们的 javascript 库中实现我的兴趣点。
这是我的 json 输出:
"{"id":19385,"first":"KIRLY","last":"MAELLI","trainer_address1":"19 NE 111TH COT","trainer_address2":null,"CITY":"MIMI","STATE":"FL","trainer_zip":"379","trainer_phone":"(-6490","trainer_fax":null,"trainer_cell":"(-6490","website_trainer_id":115,"trainer_email":"MOBA@YAHOO.COM","trainer_group":"","inactive":null}",
"{"id":19386,"first":"CHY","last":"MEH","trainer_address1":"1014 ROAD","trainer_address2":null,"CITY":"MIORD","STATE":"DE","trainer_zip":"63","trainer_phone":"","trainer_fax":null,"trainer_cell":"(-8811","website_trainer_id":118,"trainer_email":"CAH@AOL.COM","trainer_group":"","inactive":null}",