1var cidadeLocation = { lat: 0, lng: 0 }; 2var initialZoom = 10; 3var markerZoom = 10; 4var marcaAnterior; 5var pressed = document.getElementById("local"); 6 7function initMap(id, config) { 8 if(typeof google === 'object' && typeof google.maps === 'object') { 9 if (!id) id = "map"; 10 if (!config) 11 config = { 12 center: cidadeLocation, 13 zoom: initialZoom, 14 styles: [ 15 { 16 featureType: "poi", 17 elementType: "all", 18 stylers: [{ visibility: "off" }] 19 } 20 ] 21 }; 22 23 return new google.maps.Map(document.getElementById(id), config); 24 } 25} 26 27function addMarker(map, coordinates, title, callback) { 28 var marker = new google.maps.Marker({ 29 position: coordinates, 30 map: map, 31 draggable: callback != null, 32 title: title 33 }); 34 35 marker.addListener("dragend", function(event) { 36 getLocationByLatLng( 37 map, 38 objectLatLng(event.latLng.lat(), event.latLng.lng()), 39 callback 40 ); 41 }); 42 43 return marker; 44} 45 46function addMarkerUnique(map, coordinates, title, callback) { 47 if (map.marcaAnterior) map.marcaAnterior.setMap(null); 48 49 map.marcaAnterior = addMarker(map, coordinates, title, callback); 50 map.setZoom(markerZoom); 51 map.panTo(coordinates); 52} 53 54function getLocation(map, search, callback) { 55 var geocoder = new google.maps.Geocoder(); 56 geocoder.geocode(search, function(results, status) { 57 if (status == google.maps.GeocoderStatus.OK) { 58 var formattedAddress = results[0].formatted_address; 59 var latitude = results[0].geometry.location.lat(); 60 var longitude = results[0].geometry.location.lng(); 61 62 coordinates = objectLatLng(latitude, longitude); 63 if (search.location) coordinates = search.location; 64 addMarkerUnique(map, coordinates, formattedAddress, callback); 65 66 if (callback) 67 callback({ address: formattedAddress, location: coordinates }); 68 } else { 69 alert("Não foi possÃvel encontrar o local"); 70 } 71 }); 72} 73 74function objectLatLng(lat, lng) { 75 return { lat: parseFloat(lat.toFixed(7)), lng: parseFloat(lng.toFixed(7)) }; 76} 77 78function getLocationByAddress(map, address, callback) { 79 getLocation(map, { address: address }, callback); 80} 81 82function getLocationByLatLng(map, coordinates, callback) { 83 getLocation(map, { location: coordinates }, callback); 84} 85
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.