Google Maps API Tutorial -3


How to get which area of map user is looking at?

  1. var boundary=map.getBounds();

Boundary varible contains latitude and longitude of two corners of a map. This represents the rectangle shown at map. You can add a event listner to always retrun you these boundary co-ordinates whenever user moves map or zoomIn/Zoom our. Eg. At below code a function “show_cities” is called whenvever map shown to user is changed.

  1.  
  2. map = new GMap2(document.getElementById("map"));
  3. map.addControl(new GLargeMapControl());
  4. map.setCenter(new GLatLng(18.520469,73.856621), 8);
  5. GEvent.addListener(map, "moveend", function()
  6. {
  7. var boundary=map.getBounds();
  8. //                    show_cities(boundary,0);
  9. });

Marker ManagerAdding a large number of markers to a Google map may both slow down rendering of the map and introduce too much visual clutter, especially at certain zoom levels. The marker manager utility provides a solution to both of these issues, allowing efficient display of hundreds of markers on the same map and the ability to specify at which zoom levels markers should appear.

While adding markers using Markermanager you can define their min and max zoom levels. Markers will be shown at this zoom level range only. This is very useful when you have so many markers to show on a map.
e.g. you are showing marker for each registered user at site and there are thousands of users to your site. Best way  is to user marker manager showing only one icon representing each country at large zoom level. At intermediate zoom level you can show icons representing states and at detailed zoom level actual icons representing user locations can be shown. This elimiates the cluttered view of showing thousands of icons at higher zoom level.

More References to learn about Google map -
Google Maps API Developers Guide http://code.google.com/apis/maps/documentation/index.html
Discussion Group http://groups.google.com/group/Google-Maps-API
Google Map API References http://code.google.com/apis/maps/documentation/reference.html
Gallary of Demos http://code.google.com/apis/maps/documentation/demogallery.html

Have you liked it? Why not help me by sharing this :
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

Leave a comment

Your comment