Using some ideas extrapolated from here:

http://forevermore.net/photozoom/

I developed this code which works great:

function onMapLoad() {
  map = new GMap2(document.getElementById("WellMap"));
  map.setCenter(new GLatLng(47.563, -122.730385), 11);
  map.addMapType(G_PHYSICAL_MAP);
  map.setMapType(G_PHYSICAL_MAP);
  map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

  for(var layer in layers) {
    addTR(layer, layers[layer].name);
    document.getElementById(layer).checked = layers[layer].checked;
    toggleGeoXML(layer, layers[layer].checked);
  }

function addGeoXML() {
  var theUrl = document.getElementById("url").value;
  theUrl = theUrl.replace(/^\s+/, "");
  theUrl = theUrl.replace(/\s+$/, "");
  if (theUrl.indexOf(' ') != -1) {
    alert('Error - that address has a space in it');
  } else {
    var id = "userAdded" + userAdded;
    layers[id] = {};
    layers[id].url = theUrl;
    layers[id].name = "User Layer " + userAdded;

    addTR(id);
    document.getElementById(id).checked = true;
    toggleGeoXML(id, true);
    userAdded++;
  }
}

function addTR(id) {
  var layerTR = document.createElement("tr");

  var inputTD = document.createElement("td");
  var input = document.createElement("input");
  input.type = "checkbox";
  input.id = id;
  input.onclick = function () { toggleGeoXML(this.id, this.checked) };
  inputTD.appendChild(input);

  var nameTD = document.createElement("td");
  var nameA = document.createElement("a");
  nameA.href = layers[id].url;
  var name = document.createTextNode(layers[id].name);
  nameA.appendChild(name);
  nameTD.appendChild(nameA);

  layerTR.appendChild(inputTD);
  layerTR.appendChild(nameTD);
  document.getElementById("sidebarTBODY").appendChild(layerTR);
}

function toggleGeoXML(id, checked) {
  if (checked) {
    var geoXml = new GGeoXml(layers[id].url);
    layers[id].geoXml = geoXml;
    var C = map.getCenter();
    var mapzoom = map.getZoom();

    if (layers[id].zoom) {
      var new_zoom=(layers[id].zoom)
      if (new_zoom > mapzoom) map.setZoom(layers[id].zoom);
    }
    else {map.setZoom(mapzoom);
    }
    if (layers[id].lat && layers[id].lng) {
        var centerlng= C.lng();
        var centerlat= C.lat();
        var maptotal = centerlat + centerlng;
        var newtotal=layers[id].lat+layers[id].lng;
        }else {map.setCenter(new GLatLng(centerlat,centerlng))}

        if (newtotal != -75.167385){
                map.setCenter(new GLatLng(layers[id].lat, layers[id].lng));
                } else {map.setCenter(new GLatLng(centerlat,centerlng));}


if (layers[id].map) {
    var nowmap= map.getCurrentMapType();}
    else{map.setMapType(G_NORMAL_MAP);}

if (nowmap!=G_NORMAL_MAP){
      map.setMapType(layers[id].map);
    } else{map.setMapType(G_NORMAL_MAP);}

    map.addOverlay(geoXml);

 }else if (layers[id].geoXml) {
    map.removeOverlay(layers[id].geoXml);
  }}
}

On Feb 26, 8:31 am, Dommer <[email protected]> wrote:
> I could use a few pointers, just to get an idea on where to start with
> this problem.
>
> My map:  http://freeforthepicking.com/WaterResources/WaterResourcesMap.html
>
> Essentially, when you click on a polygon, things go great.
>
> When you click on 2 polygons, it defaults to the zoom settings of the
> polygon you clicked last.  So, if you had already zoomed in to a
> property in footprints and then you added another layer you had lost
> all of that zooming.
>
> What I need to do is have the map check the current map settings, if
> the center isn't the default map center; don't change it.  If the zoom
> level for the map the user checks is lower than the present zoom
> level, don't change the zoom level.
>
> What functions can I use to get the mapper to do checks like this of
> the state of the map before deciding whether or not to perform a
> function like zooming out or changing the map center?
>
> Thanks in advance.
> Help me out and get a cookie!
>
> Dominic
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to