Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable clickable landmark on google map

I'm using google map API v3. I want to disable click action on default google landmark/poi. For example, when I zoom to UCLA, the school icon shows up (that's fine) but I don't want user to click and view details of that location. Which API function should I use?

like image 541
Clark Avatar asked Sep 01 '11 08:09

Clark


People also ask

Can I turn off the markers in Google Maps?

Hover your cursor over the box and wait until more options appear. Click “More” to open the Map Details menu. Under “Map Type,” you'll see a checked box next to “Labels.” Uncheck it to remove all labels.

How do I remove a default marker from Google Maps?

Just set clickableIcons: false in the options you initialise the Map with. I added an example, you have to zoom enough to see those points. Thank you! These POI's should be turned off by default in the APi.

How do I hide a button on Google Maps?

Adding or removing controls from the map is specified in the Map options object. Set the control to true to make it visible - Set the control to false to hide it.


3 Answers

Google has exposed an option for this. See clickableIcons of google.maps.MapOptions in the docs.

Example initialization code:

map = new google.maps.Map(document.getElementById('map'), {
    clickableIcons: false
});
like image 123
Patrick Berkeley Avatar answered Oct 13 '22 01:10

Patrick Berkeley


add this option to mapOption clickableIcons: false

this is more options i think you will

draggable: true, // this is for disable the Draggable
disableDefaultUI: true, // this for disable Default UI
fullscreenControl: false, // this is for disable Full Screen
scrollwheel: true, // this is for disable Scroll Wheel
disableDoubleClickZoom: false, // this is for disable Double Click Zoom
draggableCursor:'crosshair',// this is for cursor type
draggingCursor:'move', // this is for dragging cursor type
minZoom: 3, // this is for min zoom for map
maxZoom: 18 , // this is for max zoom for map
//note : max, min zoom it's so important for my design.
zoom: 14, // this is to make default zoom
clickableIcons: false, // this is to disable all labels icons except your custom infowindow or Infobox.
like image 22
duhok Avatar answered Oct 13 '22 01:10

duhok


I encountered this same problem. Google appears to have recently changed their api to make the base map labels "clickable" and there is not yet a simple API call to disable their clickablility. http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f1ac9ad4da3606fe

I would like to see google add a simple map option like this, but alas it doesn't exist yet

var opts = { clickableLabels:false };
var map = new maps.google.com.map(div,opts);

The following solution works, but because it relies on custom styled map tiles, free maps are limited to (2,500 maps loads per day) - See Google Maps FAQ.

function initialize() {

  // For more details see 
// http://code.google.com/apis/maps/documentation/javascript/styling.html
  var noPOILabels = [
    { 
      featureType: "poi", 
      elementType: "labels", 
      stylers: [ { visibility: "off" } ] 

    }
  ];

  // Create a new StyledMapType object, passing it the array of styles,
  // as well as the name to be displayed on the map type control.
  var noPOIMapType = new google.maps.StyledMapType(noPOILabels,
    {name: "NO POI"});

  // Create a map object, and include the MapTypeId to add
  // to the map type control.
  var mapOptions = {
    zoom: 11,
    center: new google.maps.LatLng(55.6468, 37.581),
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'no_poi']
    }
  };
  var map = new google.maps.Map(document.getElementById('map_canvas'),
    mapOptions);

  //Associate the styled map with the MapTypeId and set it to display.
  map.mapTypes.set('no_poi', noPOIMapType);
  map.setMapTypeId('no_poi');
}
like image 7
Glenn Avatar answered Oct 13 '22 02:10

Glenn