ThinkGeo.com    |     Documentation    |     Premium Support

Map zoom and locate()

I’m using the Overlays sample as the basis for a current position-tracking, overhead map display Web site. This generally works, but, when the user zooms in on his map, the map will, after a few seconds, zoom back out to some level (always the same level).

I’m using the Leaflet branch of the Overlays sample and mostly Bing overhead maps, but the same effect occurs with Google Maps and street map “mode”.

I’m testing on Android N with the latest updates (7.0) and Chrome.

I don’t see anything in the JavaScript code that should be redrawing the map. I’ve adjusted the maxZoom setting to 20,. matching the default maximum zoom for the location-disabled configuration.

Is this some restriction or requirement that I’ve missed? Are we only permitted to show location on a map with a certain zoom level? Where is this enforced? My Bing Maps key doesn’t carry this restriction so I’d like it to work correctly.

Thanks!
Paul T.

Hi Paul,

For WebAPI, our map only works on server side, and provide the tile images to client side. So we cannot limit the area or zoomlevel, the tile image will be generated depend on the parameters sent back from client side.

If the map works strange, that’s maybe because you missed some setting in Leaflet. In fact we don’t have more experience on Leaflet, so maybe we cannot give you more detail suggestion about this library. I think you can do something like this: View the sending request when you zoom in and auto zoom back(f12 or fiddler), the sending request should contains bbox or zoomlevel or col/row number, so you can know whether it’s really automatic back to original level or it’s just looks like that.

And if possible you can upload a simple video or sample project, so we can help you look into it.

Regards,

Don

Sure. The sample project is basically your Overlays project but with Location added from another sample, GettingStarted. I’ve unloaded the Overlays.OpenLayers project to concentrate on Leaflet. I run the Web API server using IIS Express, with SSL enabled, and using Conveyor to create an externally-visible port for my phone to connect. I’m attaching a ZIP file containing the solution for VS2017.

Note that IIS Express installed with VS2017 15.3.3 has a problem with SSL which I’ve reported and which Microsoft will fix soon. You may need to install IIS Express 10.0 from www.microsoft.com/download in place of the one installed with VS, if you’re using the VS version mentioned.

Since your upload capability is severely limited, I’ve copied a ZIP containing the project here:

https://drive.google.com/open?id=0B8xst4oyC2htOTJBTFRub1BROWc

Paul T.

I’ve attached the Android device to my PC and captured the Chrome console. Nothing in the thinkgeo.js file is happening when the zoom level is “magically” updating. Watching what does happen suggests to me that the “tracking” operation associated with the map may be responsible, as I thought, but that it may be happening deeper in the code (Leaflet? Inside ThinkGeo?)

I’ll continue to experiment…

So disabling setView or watch in the locate() call stops the automatic resize/repan operation, so this seems to be a feature of Leaflet. I’ll dig into it on that end of the stack. Ideally, I’d like to allow the user to adjust the zoom and/or center and still track the location without automatically adjusting the view boundaries. If he taps ‘locate me’ again, those controls should switch back ON.

Hi Paul,

Thanks for your sample, you can delete the packages&bin&obj folder, which takes so big size.

I run the sample without any problem, but it looks I cannot reproduce this problem, and because I am using 2015 I hadn’t installed any fix.

My test steps: keep zoom and pan on the map, wait 5~10 seconds each time I zoom in or zoom out, but I hadn’t met the map auto zoom back. I guess maybe I missed something, please let me know the correct test steps.

Regards,

Don