1/** 2 * Scripts for Fusion Map Extension 3 */ 4 5// Google Maps Function 6function fsn_google_maps_init(lat,lng,mapID,places,zoomLevel,mapType,zoomControl,zoomControlPosition,typeControl,typeControlStyle,typeControlPosition, mapStyles,scaleControl){ 7 var infowindow = null; 8 var latlng = new google.maps.LatLng(lat,lng); 9 10 if(mapType == 'ROADMAP'){ 11 mapType = google.maps.MapTypeId.ROADMAP; 12 }else if(mapType == 'SATELLITE'){ 13 mapType = google.maps.MapTypeId.SATELLITE; 14 }else if(mapType == 'HYBRID'){ 15 mapType = google.maps.MapTypeId.HYBRID; 16 }else if(mapType == 'TERRAIN'){ 17 mapType = google.maps.MapTypeId.TERRAIN; 18 } 19 20 if(typeControlStyle == 'DEFAULT'){ 21 typeControlStyle = google.maps.MapTypeControlStyle.DEFAULT; 22 }else if(typeControlStyle == 'HORIZONTAL_BAR'){ 23 typeControlStyle = google.maps.MapTypeControlStyle.HORIZONTAL_BAR; 24 }else if(typeControlStyle == 'DROPDOWN_MENU'){ 25 typeControlStyle = google.maps.MapTypeControlStyle.DROPDOWN_MENU; 26 } 27 28 mapStyles = JSON.parse(mapStyles); 29 30 var options = { 31 center: latlng, 32 mapTypeId: mapType, 33 zoomControl: zoomControl, 34 zoomControlOptions: { 35 position: zoomControlPosition 36 }, 37 mapTypeControl: typeControl, 38 mapTypeControlOptions: { 39 style: typeControlStyle, 40 position: typeControlPosition 41 }, 42 fullscreenControl: false, 43 scaleControl: scaleControl, 44 streetViewControl: false, 45 zoom: zoomLevel, 46 gestureHandling: 'cooperative', 47 styles: mapStyles, 48 }; 49 var map = new google.maps.Map(document.getElementById(mapID), options); 50 for (i = 0; i < places.length; i++) { 51 if (places[i]['marker']['icon']) { 52 var icon = fsnMapGetItemIconObject(places[i]['marker']['icon']); 53 var marker = new google.maps.Marker({ 54 icon: icon, 55 position: places[i]['marker']['position'], 56 map: map, 57 content: places[i]['infoWindow']['content'] 58 }); 59 } else { 60 var marker = new google.maps.Marker({ 61 position: places[i]['marker']['position'], 62 map: map, 63 content: places[i]['infoWindow']['content'] 64 }); 65 } 66 if (places[i]['infoWindow']['open'] == 'true') { 67 infowindow = new google.maps.InfoWindow({ 68 content: places[i]['infoWindow']['content'] 69 }); 70 infowindow.open(map, marker); 71 // var center = map.getCenter(); 72 // map.setCenter(center); 73 infowindow.addListener('closeclick', ()=>{ 74 if(fsn_google_map_screen_reader == true) { 75 fsnGoogleMapRemoveTabindex(mapID); 76 } 77 }); 78 } 79 google.maps.event.addListener(marker, 'click', function() { 80 fsnGoogleMapRemoveTabindex(mapID); 81 if (infowindow) { 82 infowindow.close(); 83 } 84 infowindow = new google.maps.InfoWindow({ 85 content: this.content 86 }); 87 infowindow.open(map, this); 88 infowindow.addListener('closeclick', ()=>{ 89 if(fsn_google_map_screen_reader == true) { 90 fsnGoogleMapRemoveTabindex(mapID); 91 } 92 }); 93 }); 94 } 95 96 //Remove tabindex from map items 97 if(fsn_google_map_screen_reader == true) { 98 google.maps.event.addListener(map, "tilesloaded", function(){ 99 fsnGoogleMapRemoveTabindex(mapID); 100 }); 101 google.maps.event.addListener(map, "idle", function(){ 102 fsnGoogleMapRemoveTabindex(mapID); 103 }); 104 } 105 106 //recenter map on resize 107 google.maps.event.addDomListener(window, "resize", function() { 108 var center = map.getCenter(); 109 google.maps.event.trigger(map, "resize"); 110 map.setCenter(center); 111 }); 112} 113 114function fsnGoogleMapRemoveTabindex(mapID) { 115 window.setTimeout(() => { 116 [].slice.apply(document.getElementById(mapID).querySelectorAll('button')).forEach(function(item) { 117 item.setAttribute('tabindex','-1'); 118 }); 119 [].slice.apply(document.getElementById(mapID).querySelectorAll('a')).forEach(function(item) { 120 item.setAttribute('tabindex','-1'); 121 }); 122 [].slice.apply(document.getElementById(mapID).querySelectorAll('div')).forEach(function(item) { 123 item.setAttribute('tabindex','-1'); 124 }); 125 }, 500); 126} 127 128function fsnMapGetItemIconObject(icon) { 129 var customMarkerUrl = icon.url; 130 var customMarkerWidth = parseInt(icon.width); 131 var customMarkerHeight = parseInt(icon.height); 132 var customMarkerAnchorX = customMarkerWidth/2;
133 switch(icon.anchorPosition) { 134 case 'bottom_center': 135 var customMarkerAnchorY = customMarkerHeight; 136 break; 137 case 'center': 138 var customMarkerAnchorY = customMarkerHeight/2; 139 break; 140 } 141 var customMarkerObject = { 142 url : customMarkerUrl, 143 scaledSize : { 144 width : customMarkerWidth, 145 height : customMarkerHeight 146 }, 147 anchor : new google.maps.Point(customMarkerAnchorX, customMarkerAnchorY) 148 }; 149 return customMarkerObject; 150}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.