I have a map which doesn't show any markers, I also have the array
echoing on screen so I know the array is working properly. The issue is
getting the echo'd arrow to communicate with my google map. Can someone
please help me? I have outlined in the code where the issue is (it's
close to the bottom).
var map;
var icon = new google.maps.MarkerImage(
'combined.png',
new google.maps.Size(32,46),
new google.maps.Point(0,0),
new google.maps.Point(16,46)
);
var center = null;
var map = null;
var currentPopup;
var bounds = new google.maps.LatLngBounds();
function addMarker(lat, lng, info) {
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map,
title: name
});
var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 300
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0, 0),
zoom: 14,
mapTypeId: google.maps.MapTypeId.TERRAIN,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
});
///////////////PROBLEMS START HERE/////////////////////////
var map_list = <?php echo json_encode( $map_list ); ?>;
for( var i = 0; i < map_list.length; i++ )
{
var contacts_name = map_list[i]['first_name']." ".['last_name'];
var contacts_lat = map_list[i]['current_location']['name'];
var contacts_lat = map_list[i]['lat'];
var contacts_lon = map_list[i]['lon'];
echo ("addMarker(['lat'],
['lon'],'<b>['first_name']."
".['last_name']</b><br/>['current_location']['name']');\n");
}
/////////////////////PROBLEMS END HERE//////////////////////////
center = bounds.getCenter();
map.fitBounds(bounds);
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.