Cmafai


Is there a way to store the current map boundaries in a variable somewhere Or is there a way to find the latitude of the center of the map view, and the longitude, but have them in two separate variables, not a lat/long pair Maybe this isn't the best way to go about it, but I want to make sure the user doesn't go outside a certain region of the map. Basically I need to define a rectangular bounding box and make is so they cannot go outside of that. Is that possible

Thanks in advance,
Cecchi MacNaughton

P.S. Sorry if the two threads I have started seem too similar =\



Re: Get Map Boundaries

Jared H


Yep, just look in the reference material here for the map methods GetCenter, GetTop, and GetLeft. That will give you all the references to the VELatLong objects you need. Then all you'd need to do is attach custom client handlers for things like onstartcontinuouspan, onstartzoom and make sure your users aren't Geosurfing where you don't want them to go.






Re: Get Map Boundaries

Cmafai

Yes, I know how to do that, but does GetTop return the latitude of the top of the map, or does it return a LatLong pair for the top center pixel

Does something as simple as "Latitude.GetCenter( )" give the latitude of the center

Edit: This is what I have now, but it doesn't work for some reason:

Code Snippet

function panControl()
{
var latlon = map.GetCenter();
var lat = latlon.Latitude;
var lon = latlon.Longitude;

if(lat > '-53.81059781') {
map.SetCenter('-53.81059781', lon);
}
}


I have it set to trigger "onendpan". Now I also have to figure out why the map shows up when I run it locally, but not when I upload it to a server =\





Re: Get Map Boundaries

SoulSolutions

Latitiude and Longitude are doubles so I surprised if it works with ''.

And you need to pass a VELatLong object so try:

Code Snippet
function panControl()
{
var latlon = map.GetCenter();
var lat = latlon.Latitude;
var lon = latlon.Longitude;

if(lat > -53.81059781) {
map.SetCenter(new VELatLong(-53.81059781, lon));
}
}

That said I have not seen anyone acheive the "locked map" with some weird effects for the user.

John.






Re: Get Map Boundaries

Cmafai

That worked perfectly! Thanks! Do you know any reason why my map might not be showing up when I upload it to my server, but does show up when I run it locally I think it is because I have stashed my mapcruncher layer in the middle of the ocean, and a high zoom level. Would that cause it to think that there shouldn't be images at that level, so it shows up blank It is still odd that it works fine when running it offline.

Thanks again Smile