Display Leaflet map per country - html

I'm developing a mobile application on phonegap.
For the Geolocation I'm using Leaflet "a JavaScript library for mobile-friendly maps"
and I just want to know if it is possible to display the map per country without having access to the others. So the user can just navigate in his country.

Leaflet allows you to set limits on zooming and panning.
One solution would be to just limit the viewable area of the map to the coordinates needed for certain countries.
I am quite sure that there is geodata available out there giving you the highest/lowest latitude and longitude values per country (sort of a bounding box around a countries borders), so you could just limit the viewable area to those values.
To limit the viewable area use
Map.maxBounds(..LatLngBounds..)
More here http://leafletjs.com/reference.html

According to this bug in the GitHub issue tracker for Leaflet, it seems that this is not possible at the moment.

Related

API to display the nearest photos to a long/lat location from Google Maps Views (like Panoramio)

Forgive me if this has already been asked but searching on 'Google Maps Views' brings up rather a lot of irrelevant hits.
Is there an API to display the nearest (say) 5 photos to a particular long/lat location from the photos available on Google Maps Views? I don't particularly need them on a map, just to embed thumbnails of the photos and link to the originals.
eg I have a page for Callanish stone circle. Could I embed images from Views based on a long/lat query?
Here's what is on Views for that location:
https://www.google.com/maps/views/explore?hl=en&gl=gb&vm=1&ll=54.596562,-3.104517&bd=54.586641,-3.121855,54.606481,-3.087179&z=15&pv=2
I read that Views is what is supposed to be taking over from Panoramio. I know Panoramio had an API but that's being shut down.
If this is possible, does anyone have an example of something similar? Showing photos on a map would be OK if that's the only way to do it.
Many thanks
Andy
http://www.megalithic.co.uk/article.php?sid=42
The Google Maps API can do it and the imagery carousel at the bottom of Google Maps website is a good example of it.
Nearest photos
You can retrieve the nearest photos to a location using the Places Photo feature, which is part of the Places library. As you want multiple photos, you need to use Place Details requests - function getDetails(). It will return up to ten PlacePhoto objects.
You probably want to submit a small height/width since you create thumbnails. And send another request with a larger height/width when a thumbnail is clicked.
Nearest Street View panorama
If, by chance, a road close to Callanish stone circle has been photographed by Street View, you can add this imagery as well.
Requests for Street View panoramas include a radius parameter. The callback function returns the nearest imagery within the requested radius. See this example. Thereby, you can retrieve one panorama by passing a very large radius.

Google Maps API v3 - Zooming to city height after a place search

Is there a way to adjust the zoom Depending on the item searched, say if somebody searched on my application for a city/country/location, the viewport returned will be a bit higher than the city, So all of the city will be Included.
I know if you have several places you can do fitBounds(); but what if it's only one place like a location/country/city
Is there a way of setting the zoom a bit higher than that location?
Google's geocoder API returns the viewport coordinates of the searched object - see the documentation for an example. You can feed the viewport coordinates to the fitBounds method.

Google maps search by address component

I have implemented a basic google places autocomplete in my web app, for example saying "Heraclion, Crete" and it translates it to the latlng coordinates that I want. I also used the mysql radius example from the api to show nearest entries. I also have locations in a second area of Crete, called "Rethymnon".
The problem now is the following. Supposedly one types just Crete. How can I get all the entries from Heraclion and Rethymnon? My code uses the radius approach as mentioned before. So I need something else to define it in a rectangular area.
Is this possible?
If the result contains a viewport (LatLngBounds), you could use that.
PlaceResult
geometry: The Place's geometry-related information. This includes:
location provides the latitude and longitude of the Place.
viewport defines the preferred viewport on the map when viewing this Place

google maps : put markers all over visible section on Google map display

I want to show limited numbers of markers(let's take 50 or so...) at all zoom level and in a manner that markers covers all entire Google map display.
So, If I am viewing whole world in map, it will show markers all over the world not to exceed a certain number, and the if I zoomed to USA it will only show previous number of markers only inside USA.
And then again if I moved to Canada , then the map should show markers of Canada only.
I am not able to
- put makers on visible region over the map on limited distances
i.e. all the visible markers maintaining somewhat some distance from each other.
You might want to look into 'clustering' or 'bunching' the points into one. It doesn't do exactly what you are describing, but it will effectively limit the number of markers you have when you are zoomed out, and 'uncluster' them once you zoom in.
There are quite a few ways (all third party - the Google API doesn't support it yet), you could have a look here at one called ClusterMarker: http://googlemapsapi.martinpearman.co.uk/articles.php?cat_id=1.
You should use a marker manager!
See http://code.google.com/p/gmaps-utility-library-dev/ and http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/

Can I limit users to a specific range and zoom level on Google Maps?

I'm implementing a Google Map on a web-page. For the purpose of this project, I want to limit how far users can drag the map, so that they can only view a certain area that falls within two co-ordinates (one specifies north-west, the other, south-east, if you get my meaning).
What's the best way to implement this using the Google Maps API?
Is there a method I can call that will do this automatically?
This method does what you want: http://econym.org.uk/gmap/range.htm