1

Hi there i'm using JMapViewer to show maps in my swing app and I've successfully created a panel with map tiles on it but these map tiles are of a particular area used in demo source of Map Viewer, i'm confused about how can i show the tiles of some particular area i want. Just like Google maps i want to show some location of my country (Pakistan) in the maps and i don't know how can i do it. Secondly, Please explain what are Layer's and Layer Group in JMapViewer? Just an idea.

Edit: how can i download tiles of Islamabad region and then add them to maps. What i've learnt from demo is this:

private void loadMapTiles(){
     map().setTileSource(new OsmTileSource.Mapnik());
     map().setTileLoader(new OsmTileLoader(map()));
}

But this shows some specific area they have set to.

I've downloaded JTileDownloader but i'm confused about the url thing because i don't now where to get the url of some specific area.

Gordon
  • 312,688
  • 75
  • 539
  • 559

1 Answers1

1
  1. Given a JMapViewer named map, something like this should display Islamabad:

    Coordinate c = new Coordinate(33.7167, 73.0667);
    map.setDisplayPosition(c, 10);
    
  2. org.openstreetmap.gui.jmapviewer.Demo, included in the distribution, is a complete example that illustrates how to use Layer. Click the Tree Layers Visible checkbox to see the effect.

Addendum: Here's the result using MapQuest-OSM at 11x zoom; Mapnik seems to work, too. If no TileSource includes the tiles you want, you may need one of the approaches mentioned here.

Islamabad Mapnik

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • how can i download tiles of Islamabad region and then add them to maps. What i've learnt from demo is this: private void loadMapTiles(){ map().setTileSource(new OsmTileSource.Mapnik()); map().setTileLoader(new OsmTileLoader(map())); } But this shows some specific area they have set to. I've downloaded JTileDownloader but i'm confused about the url thing because i don't now where to get the url of some specific area. –  Aug 09 '14 at 10:13
  • If no `TileSource` includes the tiles you want, you may need one of the approaches mentioned [here](http://stackoverflow.com/q/22805302/230513). – trashgod Aug 09 '14 at 10:23
  • Sir i'm very new to JMapViewer, All i know is the demo code which comes with the release. I want exactly what you have shown in the above image but for bahria Town lahore pakistan And i want to restrict my panel to show only this area's map. where do i get the code of above mentioned frame so that i may study it and try to understand what is going on. –  Aug 09 '14 at 17:19
  • I'm not sure where you're having trouble; please edit your question to include a complete [example](http://stackoverflow.com/help/mcve) that includes a `Coordinate` for Lahore. – trashgod Aug 09 '14 at 18:55
  • sir as i have added the map of Pakistan now, how can i restrict my mapPanel to view only the map of this area and no other area. –  Aug 15 '14 at 17:07
  • You can customize the `DefaultMapController`, as shown [here](http://stackoverflow.com/a/24688091/230513). – trashgod Aug 15 '14 at 23:30