From 52fc2fb088d075a1c54433f517c7ee1a34a89a89 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 29 Dec 2013 18:49:08 +0000 Subject: fixed add location marker --- map3.js | 55 ++++++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/map3.js b/map3.js index 2f40e11..30a3158 100644 --- a/map3.js +++ b/map3.js @@ -507,7 +507,8 @@ function showElements(elements) { } function centerAndZoom(lat, lng) { - map.setCenter(new google.maps.LatLng(lat, lng), 17); + map.setCenter(new google.maps.LatLng(lat, lng)); + map.setZoom(20); } function addNewNodeText(point) { @@ -518,8 +519,8 @@ function addNewNodeText(point) { var lat_startpoint = 47.07177327969; var dy_dlat = 75505.521; - var pixel_x = parseInt(Math.floor(x_startpoint + (point.lng - lng_startpoint) * dx_dlng)); - var pixel_y = parseInt(Math.floor(y_startpoint - (point.lat - lat_startpoint) * dy_dlat)); + var pixel_x = parseInt(Math.floor(x_startpoint + (point.lng() - lng_startpoint) * dx_dlng)); + var pixel_y = parseInt(Math.floor(y_startpoint - (point.lat() - lat_startpoint) * dy_dlat)); var link = 'https://manman.graz.funkfeuer.at/location/new?'; link += 'z_x=' + Math.floor(pixel_x % 100) + '&z_y=' + Math.floor(pixel_y % 100); @@ -527,10 +528,10 @@ function addNewNodeText(point) { var html = 'Neuen Knoten eintragen
Nutzen sie den Zoombereich aus!


'; html += ''; - html += ''; + html += ''; html += ''; - html += ''; + html += 'onclick="javascript:centerAndZoom(' + point.lat() + ',' + point.lng() + ')" />'; + html += ''; html += ''; html += '
Breitengrad: ' + convertCoords(point.lat) + ' 
Breitengrad: ' + convertCoords(point.lat()) + ' 
Längengrad: ' + convertCoords(point.lat)+ ' 
Längengrad: ' + convertCoords(point.lng())+ ' 
'; @@ -538,41 +539,13 @@ function addNewNodeText(point) { } function setNewMarker(point) { -/* - var marker = new GMarker(point,{icon: makeIcon('newnode'), draggable: true}); - google.maps.event.addListener(marker, "dragstart", - function() { - this.autoclosed = true; - this.closeInfoWindow(); - }); - - google.maps.event.addListener(marker, "dragend", - function(point) { - this.openInfoWindowHtml(addNewNodeText(point)); - }); - - google.maps.event.addListener(marker, "infowindowclose", - function () { - if(this.autoclosed == true) { - this.autoclosed = false; - } else { - map.removeOverlay(overlays["newmarker"]); - overlays["newmarker"] = null; - } - }); - - marker.overlaytype = "newmarker"; - map.addOverlay(marker); - marker.openInfoWindowHtml(addNewNodeText(point)); -*/ - - - var marker = new google.maps.Marker({position: point, icon: makeIcon('newnode')}); - // google.maps.event.addListener(marker,"infowindowclose",function () { - // map.removeOverlay(marker); - // }); - marker.setMap(map); - marker.openInfoWindowHtml(addNewNodeText(point)); +// TODO: if a new new marker is set: remove the old one +// TODO: make this dragable?? + var marker = new google.maps.Marker({position: point, icon: makeIcon('newnode')}); + var infowindow = new google.maps.InfoWindow({ content: addNewNodeText(point) }); + google.maps.event.addListener(infowindow,"closeclick",function () { marker.setMap(null); }); + marker.setMap(map); + infowindow.open(map,marker); } function fflogin(username, password) { -- cgit v1.2.1