Nextrek
Diff Revisions
1035
vs
1036
for /Web/Smartcharging_search/js/maps-google.js
|
@@ -21,8 +21,6 @@ |
21 |
21 |
|
lng: position.coords.longitude |
22 |
22 |
|
}; |
23 |
23 |
|
|
24 |
|
- |
var place = {name : getPlaceInfo(pos.lat, pos.lng) != false ? getPlaceInfo(pos.lat, pos.lng) : ""}; |
25 |
|
- |
|
26 |
24 |
|
var icon = { |
27 |
25 |
|
url: "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png", |
28 |
26 |
|
size: new google.maps.Size(71, 71), |
|
@@ -31,17 +29,33 @@ |
31 |
29 |
|
scaledSize: new google.maps.Size(25, 25) |
32 |
30 |
|
}; |
33 |
31 |
|
|
34 |
|
- |
// Create a marker for place. |
35 |
|
- |
markers.push(new google.maps.Marker({ |
36 |
|
- |
map: map, |
37 |
|
- |
icon: icon, |
38 |
|
- |
title: 'Posizione Attuale', |
39 |
|
- |
position: pos |
40 |
|
- |
})); |
41 |
|
- |
|
42 |
32 |
|
map.setCenter(pos); |
|
33 |
+ |
|
|
34 |
+ |
var place; |
|
35 |
+ |
var geocoder = new google.maps.Geocoder(); |
|
36 |
+ |
var latlng = new google.maps.LatLng(pos.lat, pos.lng); |
|
37 |
+ |
geocoder.geocode({'latLng': latlng}, function(results, status) { |
|
38 |
+ |
if (status == google.maps.GeocoderStatus.OK) { |
|
39 |
+ |
//console.log(results) |
|
40 |
+ |
if (results[1]) { |
|
41 |
+ |
//formatted address |
|
42 |
+ |
place = {name : results[0].formatted_address}; |
|
43 |
+ |
} else { |
|
44 |
+ |
place = {name : ""}; |
|
45 |
+ |
} |
|
46 |
+ |
// Create a marker for place. |
|
47 |
+ |
markers.push(new google.maps.Marker({ |
|
48 |
+ |
map: map, |
|
49 |
+ |
icon: icon, |
|
50 |
+ |
title: place.name, |
|
51 |
+ |
position: pos |
|
52 |
+ |
})); |
|
53 |
+ |
getMarkersBySearch(place, pos.lat, pos.lng, markers, window.tipologies, infowindow, map, iconSmart, contents); |
|
54 |
+ |
} else { |
|
55 |
+ |
alert("Posizione non trovata"); |
|
56 |
+ |
} |
|
57 |
+ |
}); |
43 |
58 |
|
|
44 |
|
- |
getMarkersBySearch(place, pos.lat, pos.lng, markers, window.tipologies, infowindow, map, iconSmart, contents); |
45 |
59 |
|
|
46 |
60 |
|
}, function() { |
47 |
61 |
|
handleLocationError(true, markers, map.getCenter()); |