offsetting center of maps
I figured out how to change the zoom level using map.setCenter, now I want the default the be on the right side of the screen, instead of center. How to I adjust that?
I figured out how to change the zoom level using map.setCenter, now I want the default the be on the right side of the screen, instead of center. How to I adjust that?
I'm not sure what you're trying to accomplish here. Are you trying to position the map on the right side of the page or are you trying to set the default location on the map to be on the right side of the map?
Where the map s placed is fine, I just want the default location, which is right now in the center of the map, to be on the right side so that all the locations (which are right now off the map on the left side) show up.
So the map.setCenter(new GLatLng(30, -98), 3); function does set the zoom, but it also centers the map on the latitude and longitude that is specified.
If you want the map to be centered on a different point, you should use this function to center the map. You will have to find the longitude and latitude of the location you want the map to be centered on. The openInfoWindowHtml will center the map on the marker that the info window is for however, so you will have to remove these function calls from your wagmp_map_[num] file to use setCenter for centering the map.
When removing the openInfoWindowHtml code, what part would I delete?
Here is a sample of the bottom of the code
if (address_3.addressType == "coordinates") {
var cacheReturn = '';
} else {
var cacheReturn = searchCache(address_3.full, address_3.zip);
}
if (cacheReturn != "" || (address_3.addressType == "coordinates")) {
if(address_3.addressType == "coordinates") {
var latitude = address_3.latitude;
var longitude = address_3.longitude;
} else {
var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
}
var point = new GLatLng(latitude, longitude);
if (point && !isNaN(latitude)) {
wagmp_map_1_obj.addressFailed = false;
var marker_3 = new GMarker(point, icon_3);
GEvent.addListener(marker_3, 'click', function() {
marker_3.openInfoWindowHtml(address_3.infowindowtext);
});
if(!fromAddress.enabled || 'address_3' != 'address_3') {
if('address_3' == 'address_3')
map.setCenter(point, 6);
map.addOverlay(marker_3);
if('address_3' == 'address_3')
marker_3.openInfoWindowHtml(address_3.infowindowtext);
}
wagmp_map_1_obj.markers.push(marker_3);
wagmp_map_1_obj.addresses.push(address_3);
wagmp_map_1_obj.icons.push(icon_3);
wagmp_map_1_obj.points.push(point);
} else {
if (wagmp_map_1_obj.addressFailed) {
map.setCenter(new GLatLng(41, -80), 3);
}
wagmp_map_1_obj.addressFailed = true;
}
} else if (address_3.addressType == "address") {
geocoder.getLatLng (
address_3.full,
function(point) {
if(point) {
this.addressFailed = false;
addToCache(address_3.full, '', point);
var marker_3 = new GMarker(point, icon_3);
GEvent.addListener(marker_3, 'click', function() {
marker_3.openInfoWindowHtml(address_3.infowindowtext);
});
if(!fromAddress.enabled || 'address_3' != 'address_3') {
if('address_3' == 'address_3')
map.setCenter(point, 6);
map.addOverlay(marker_3);
if('address_3' == 'address_3')
marker_3.openInfoWindowHtml(address_3.infowindowtext);
}
wagmp_map_1_obj.markers.push(marker_3);
wagmp_map_1_obj.addresses.push(address_3);
wagmp_map_1_obj.icons.push(icon_3);
wagmp_map_1_obj.points.push(point);
} else {
var noZipAddress = address_3.full.replace((address_3.zip+','), '');
geocoder.getLatLng (noZipAddress,
function(point) {
if(point) {
wagmp_map_1_obj.addressFailed = false;
addToCache(address_3.full, address_3.zip, point);
var marker_3 = new GMarker(point, icon_3);
GEvent.addListener(marker_3, 'click', function() {
marker_3.openInfoWindowHtml(address_3.infowindowtext);
});
if (!fromAddress.enabled || 'address_3' != 'address_3') {
if('address_3' == 'address_3')
map.setCenter(point, 6);
map.addOverlay(marker_3);
if('address_3' == 'address_3')
marker_3.openInfoWindowHtml(address_3.infowindowtext);
}
wagmp_map_1_obj.markers.push(marker_3);
wagmp_map_1_obj.addresses.push(address_3);
wagmp_map_1_obj.icons.push(icon_3);
wagmp_map_1_obj.points.push(point);
} else {
if (wagmp_map_1_obj.addressFailed) {
map.setCenter(new GLatLng(41, -80), 3);
}
wagmp_map_1_obj.addressFailed = true;
}
}
You will need to remove all the references similar to this:
marker_3.openInfoWindowHtml(address_3.infowindowte xt);
Unless they are surrounded by the addListener function:
GEvent.addListener(marker_3, 'click', function() {
marker_3.openInfoWindowHtml(address_3.infowindowte xt);
});
The ones not in the addListener functions are run when the map is loading(as each marker is loaded). The ones in the addListener functions are triggered when you click on the marker icon.
In addition, you will want to remove all other setCenter function calls so they don't interfere with the centering you are applying.
The marker info will not show up after the map has loaded, but this allows for the center of the map to be able to be set by map.setCenter.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.