[OpenLayers-Users] change tms layer does not change map view
miguel
juanabreu at hotmail.com
Tue Sep 3 05:55:26 PDT 2013
Does anyone have any suggestion or a tip or anything. I can't believe I'm
doing something so farfetched that no one here can give me a pointer.
Miguel
From: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Juan Abreu
Sent: Saturday, August 31, 2013 4:48 AM
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] change tms layer does not change map view
I have a TMS layer that I'm using as my map, i have set it up so that users
can change the map however changing the layer does not update the map view
until i hit the zoom in button or the zoom out button. how can i refresh the
map view to show the newly added layer? here is a quick code sample. i tried
layer.redraw() without any solution. does someone have any other ideas.on a
desperate i just try setting the map div html to "" and it finally updated
the layer. is this the proper way to do this?
[code sample below]
function initMAP() {
var mapBounds = new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2],
bounds[3]);
var mapMinZoom = 0;
var mapMaxZoom = 3;
// avoid pink tiles
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
var options = {
theme: null,
controls: [
new OpenLayers.Control.Navigation({
dragPanOptions: {
// enableKinetic: true
}
}),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Zoom()
],
maxExtent: new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2],
bounds[3]),
maxResolution: 4,
numZoomLevels: 3
};
map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.TMS("TMS",
"http://mymapserver.com/MAP2/", { 'type': 'png', 'getURL': get_my_url });
map.addLayer(layer);
layer.redraw({ force: true });
map.zoomToExtent(mapBounds);
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Zoom()
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130903/251c3820/attachment.html>
More information about the Users
mailing list