close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

offsetting center of maps

Thread began 8/18/2009 11:34 am by aaron322044 | Last modified 8/20/2009 3:22 pm by Jimmy Wu | 2271 views | 5 replies |

aaron322044

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?

Sign in to reply to this post

Jimmy Wu

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?

Sign in to reply to this post

aaron322044

postioning 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.

Sign in to reply to this post

Jimmy Wu

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.

Sign in to reply to this post

aaron322044

how to remove the code

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;
}
}

Sign in to reply to this post

Jimmy Wu

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.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...