0

I'm using gmap3 jquery plugin to show objects on google map. And while it's loading, Europe is shown on the map, then (I think when all the markers are loaded) the map switches to my location (Samara, Russia). Can I show some kind of preloader while the map is loading? You can see the real example here: http://www.roomas.ru Press "Показать на карте" tab to view the map.

webstyle
  • 25
  • 1
  • 1
  • 8

1 Answers1

2

You can show a label like "loading..." and hide it when map is ready. I used maplabel.

source: https://code.google.com/p/google-maps-utility-library-v3/source/browse/trunk/maplabel/src/maplabel.js?r=300

reference: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/maplabel/docs/reference.html

usage:

var myLatlng = new google.maps.LatLng(0,0);
var myOptions = {
  zoom: 2,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  navigationControl: true,
  mapTypeControl: true,
  scaleControl: true,
  draggable: true,
      streetViewControl:true,
      scrollwheel: false
}

map = new google.maps.Map($("#YOUR_MAP_CONTAINER_ID")[0], myOptions);

mapLabel = new MapLabel({
      text: 'Loading...',
      position: new google.maps.LatLng(map.getCenter().lat(),map.getCenter().lng()),
      map: map,
      fontSize: 35,
      strokeWeight:3,
      fontColor:'#003762',
      align: 'center'
});

mapLabel.set('position', new google.maps.LatLng(map.getCenter().lat(),map.getCenter().lng()));

To hide the label when you want:

mapLabel.set('text','');
grigno
  • 3,128
  • 4
  • 35
  • 47
  • I can't find it there. Can you give a direct link to it? – webstyle Apr 24 '13 at 07:57
  • But how can I figure out, when the map is loaded and the label should be hidden? – webstyle Apr 24 '13 at 08:14
  • try read this: http://stackoverflow.com/questions/832692/how-to-check-if-google-maps-is-fully-loaded. Hope this help you. – grigno Apr 24 '13 at 08:19
  • And how it can help in my case? If I understand everything correctly: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/maplabel/examples/maplabel.html it just adds a text on the map, it doesn't even hide the map itself. In my case it is the only way, because I can't show my visitors the wrong map while the markers are being loaded. – webstyle Apr 24 '13 at 08:21