我正在尝试显示带有一些标记(显示为标志)的传单地图,并且每个标志上应具有不同的标签(例如地址或数字)。我在php数组中有标志标签,但是我不知道如何将它们添加到标志中。 这是我得到的代码...目前所有标记都标有“ A”。
window.onload = function() {
L.mapquest.key = 'key here';
// Geocode three locations, then call the createMap callback
L.mapquest.geocoding().geocode([<?=$address?>], createMap);
function createMap(error, response) {
// Initialize the Map
var map = L.mapquest.map('map', {
layers: L.mapquest.tileLayer('map'),
center: [0, 0],
zoom: 12
});
// Generate the feature group containing markers from the geocoded locations
var featureGroup = generateMarkersFeatureGroup(response);
featureGroup.addTo(map);
map.fitBounds(featureGroup.getBounds());
}
function generateMarkersFeatureGroup(response) {
var group = [];
for (var i = 0; i < response.results.length; i++) {
var location = response.results[i].locations[0];
var locationLatLng = location.latLng;
// Create a marker for each location
var marker = L.marker(locationLatLng, {icon: L.mapquest.icons.marker({
primaryColor: '#22407F',
secondaryColor: '#3B5998',
shadow: true,
size: 'md',
symbol: 'A' })})
.bindPopup('<?=$row['address1']?><br/><a href="property-detail.php?id= <?=$row['id']?>">See details</a>')
.openPopup();
group.push(marker);
}
return L.featureGroup(group);
}
}