NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi to all,

I am using Openstreetmap with leaflet.

1.In zoom level 1, There is some empty space in bottom & top, but horizontally map tiles are repeated. But my markers shown in a single map.(refer alt textimage1.png).

Is there any option to show markers in all maps shown, or How to load or show a single map?

2.In other zoom levels, i want to disable drag when reach bottom or top of the map. Because after reach bottom or top, it will show empty spaces only(refer alt textimage2.png)

Note: In google maps it is working fine(cant drag when reach top/bottom).

asked 29 Jul '15, 08:04

Rajavelu_M's gravatar image

Rajavelu_M
253454858
accept rate: 33%

edited 29 Jul '15, 08:06

I found answer for how to disable drag?

map.dragging.disable();

But, still i dont know, how to find the map reached the top or bottom?

(31 Jul '15, 08:15) Rajavelu_M

Also tried as map.setMaxBounds([[51.490, -0.122], [51.510, -0.028]]); for disable drag when reach top/bottom. But not working(map cant drag horizontally)

(03 Aug '15, 06:47) Rajavelu_M

I've used these settings (coords changed to yours):

    var southwest = L.latLng(51.490, -0.122),
        northeast = L.latLng(51.510, -0.028),
        bounds = L.latLngBounds(southwest, northeast);

    var map = L.map('map', {
        zoom: 8,
        maxZoom: 18,
        maxBounds: bounds
    });

    map.fitBounds(bounds);
permanent link

answered 15 Aug '15, 10:22

Protect%20OSM's gravatar image

Protect OSM
111
accept rate: 0%

Hi, Still its not working to me. Can you give in fiddle, or full source(with html).

(16 Aug '15, 07:27) Rajavelu_M

Sorry for my late answer. Here's a demo:

http://www.protectosm.com/demo-disabled-dragging/

(24 Aug '15, 11:43) Protect OSM

@Protect OSM: I think you are mis-understand my question, Actually i need to disable drag when my drag reach bottom/top of the map. Currently i can drag when reach top/bottom of map, but it shows empty page.

(24 Aug '15, 11:50) Rajavelu_M

If I "overdrag" the map it shows eveything perfectly but on "drop" it bounces back fitting the original bounds.

(http://i.imgur.com/x41dtJg.jpg - cursor was over the "Leaflet" copyright in the bottom, right.)

If it's not working at you like this, there's something wrong.

Could you please give a link to your site?

(24 Aug '15, 12:03) Protect OSM

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×362
×287
×107
×74
×6

question asked: 29 Jul '15, 08:04

question was seen: 9,051 times

last updated: 24 Aug '15, 12:03

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum