1function optometry_googlemap_init(dom_obj, coords) { 2 "use strict"; 3 if (typeof OPTOMETRY_STORAGE['googlemap_init_obj'] == 'undefined') optometry_googlemap_init_styles(); 4 OPTOMETRY_STORAGE['googlemap_init_obj'].geocoder = ''; 5 try { 6 var id = dom_obj.id; 7 OPTOMETRY_STORAGE['googlemap_init_obj'][id] = { 8 dom: dom_obj, 9 markers: coords.markers, 10 geocoder_request: false, 11 opt: { 12 zoom: coords.zoom, 13 center: null, 14 scrollwheel: false, 15 scaleControl: false, 16 disableDefaultUI: false, 17 panControl: true, 18 zoomControl: true, //zoom 19 mapTypeControl: false, 20 streetViewControl: false, 21 overviewMapControl: false, 22 styles: OPTOMETRY_STORAGE['googlemap_styles'][coords.style ? coords.style : 'default'], 23 mapTypeId: google.maps.MapTypeId.ROADMAP 24 } 25 }; 26 27 optometry_googlemap_create(id); 28 29 } catch (e) { 30 31 //dcl(OPTOMETRY_STORAGE['strings']['googlemap_not_avail']); 32 33 }; 34} 35 36function optometry_googlemap_create(id) { 37 "use strict"; 38 39 // Create map 40 OPTOMETRY_STORAGE['googlemap_init_obj'][id].map = new google.maps.Map(OPTOMETRY_STORAGE['googlemap_init_obj'][id].dom, OPTOMETRY_STORAGE['googlemap_init_obj'][id].opt); 41 42 // Add markers 43 for (var i in OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers) 44 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].inited = false; 45 optometry_googlemap_add_markers(id); 46 47 // Add resize listener 48 jQuery(window).resize(function() { 49 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].map) 50 OPTOMETRY_STORAGE['googlemap_init_obj'][id].map.setCenter(OPTOMETRY_STORAGE['googlemap_init_obj'][id].opt.center); 51 }); 52} 53 54function optometry_googlemap_add_markers(id) { 55 "use strict"; 56 for (var i in OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers) { 57 58 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].inited) continue; 59 60 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].latlng == '') { 61 62 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].geocoder_request!==false) continue; 63 64 if (OPTOMETRY_STORAGE['googlemap_init_obj'].geocoder == '') OPTOMETRY_STORAGE['googlemap_init_obj'].geocoder = new google.maps.Geocoder(); 65 OPTOMETRY_STORAGE['googlemap_init_obj'][id].geocoder_request = i; 66 OPTOMETRY_STORAGE['googlemap_init_obj'].geocoder.geocode({address: OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].address}, function(results, status) { 67 "use strict"; 68 if (status == google.maps.GeocoderStatus.OK) { 69 var idx = OPTOMETRY_STORAGE['googlemap_init_obj'][id].geocoder_request; 70 if (results[0].geometry.location.lat && results[0].geometry.location.lng) { 71 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[idx].latlng = '' + results[0].geometry.location.lat() + ',' + results[0].geometry.location.lng(); 72 } else { 73 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[idx].latlng = results[0].geometry.location.toString().replace(/\(\)/g, ''); 74 } 75 OPTOMETRY_STORAGE['googlemap_init_obj'][id].geocoder_request = false; 76 setTimeout(function() { 77 optometry_googlemap_add_markers(id); 78 }, 200); 79 } else 80 dcl(OPTOMETRY_STORAGE['strings']['geocode_error'] + ' ' + status); 81 }); 82 83 } else { 84 85 // Prepare marker object 86 var latlngStr = OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].latlng.split(','); 87 var markerInit = { 88 map: OPTOMETRY_STORAGE['googlemap_init_obj'][id].map, 89 position: new google.maps.LatLng(latlngStr[0], latlngStr[1]), 90 clickable: OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].description!='' 91 }; 92 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].point) markerInit.icon = OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].point; 93 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].title) markerInit.title = OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].title; 94 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].marker = new google.maps.Marker(markerInit); 95 96 // Set Map center 97 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].opt.center == null) { 98 OPTOMETRY_STORAGE['googlemap_init_obj'][id].opt.center = markerInit.position; 99 OPTOMETRY_STORAGE['googlemap_init_obj'][id].map.setCenter(OPTOMETRY_STORAGE['googlemap_init_obj'][id].opt.center); 100 } 101 102 // Add description window 103 if (OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].description!='') { 104 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].infowindow = new google.maps.InfoWindow({ 105 content: OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].description 106 }); 107 google.maps.event.addListener(OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].marker, "click", function(e) { 108 var latlng = e.latLng.toString().replace("(", '').replace(")", "").replace(" ", ""); 109 for (var i in OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers) { 110 if (latlng == OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].latlng) { 111 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].infowindow.open( 112 OPTOMETRY_STORAGE['googlemap_init_obj'][id].map, 113 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].marker 114 ); 115 break; 116 } 117 } 118 }); 119 } 120 121 OPTOMETRY_STORAGE['googlemap_init_obj'][id].markers[i].inited = true; 122 } 123 } 124} 125 126function optometry_googlemap_refresh(id) { 127 "use strict"; 128 for (id in OPTOMETRY_STORAGE['googlemap_init_obj']) { 129 optometry_googlemap_create(id); 130 } 131} 132 133function optometry_googlemap_init_styles() { 134 "use strict"; 135 // Init Google map 136 OPTOMETRY_STORAGE['googlemap_init_obj'] = {}; 137 OPTOMETRY_STORAGE['googlemap_styles'] = { 138 'default': [] 139 }; 140 if (window.optometry_theme_googlemap_styles!==undefined) 141 OPTOMETRY_STORAGE['googlemap_styles'] = optometry_theme_googlemap_styles(OPTOMETRY_STORAGE['googlemap_styles']); 142}
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.