I am using the following code:
var geocoder;
var map;
var markers = [];
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(53.590875,-2.279663);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
addPostCode('EX4 5SP');
addPostCode('EX16 6LH');
addPostCode('M1 2AP');
}
I have found some examples of how to achieve this. In the following code: Google MAP API v3: center and scale the displayed markers to achieve this, use the following code,
var latlngbounds = new google.maps.LatLngBounds();
latlng.each(function(n){
latlngbounds.extend(n);
});
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
The problem is that I need to use zip codes to display the location on the map. Is it possible to create an array of GLatLng instances from a zip code and then use the above code to scale and center multiple markers on a map?
source
share