function addContextMenu() { // === create the context menu div === contextmenu = document.createElement("div"); contextmenu.style.visibility="hidden"; contextmenu.style.background="#ffffff"; contextmenu.style.border="1px solid #8888FF"; contextmenu.innerHTML =// '
  Zoom in  <\/div><\/a>' //+ '
  Zoom out  <\/div><\/a>' '
  Zoom in εδώ  <\/div><\/a>' + '
  Zoom out εδώ  <\/div><\/a>' + '
  Κεντράρισμα εδώ  <\/div><\/a>'; map.getContainer().appendChild(contextmenu); // === listen for singlerightclick === GEvent.addListener(map,"singlerightclick",function(pixel,tile) { // store the "pixel" info in case we need it later // adjust the context menu location if near an egde // create a GControlPosition // apply it to the context menu, and make the context menu visible clickedPixel = pixel; var x=pixel.x; var y=pixel.y; if (x > map.getSize().width - 120) { x = map.getSize().width - 120 } if (y > map.getSize().height - 100) { y = map.getSize().height - 100 } var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y)); pos.apply(contextmenu); contextmenu.style.visibility = "visible"; }); // === If the user clicks on the map, close the context menu === GEvent.addListener(map, "click", function() { contextmenu.style.visibility="hidden"; }); } // === functions that perform the context menu options === function zoomIn() { // perform the requested operation // map.zoomIn(); var point = map.fromContainerPixelToLatLng(clickedPixel) map.zoomIn(point,true); map.setZoom(15); // hide the context menu now that it has been used contextmenu.style.visibility="hidden"; } function zoomOut() { // perform the requested operation // map.zoomOut(); map.setZoom(9); // hide the context menu now that it has been used contextmenu.style.visibility="hidden"; } function zoomInHere() { // perform the requested operation var point = map.fromContainerPixelToLatLng(clickedPixel); map.setCenter(point,map.getZoom()-1); // There is no map.zoomOut() equivalent map.zoomIn(point,true); map.setZoom(15); // hide the context menu now that it has been used contextmenu.style.visibility="hidden"; } function zoomOutHere() { // perform the requested operation var point = map.fromContainerPixelToLatLng(clickedPixel) map.setCenter(point,map.getZoom()-1); // There is no map.zoomOut() equivalent map.setZoom(9); contextmenu.style.visibility="hidden"; } function centreMapHere() { // perform the requested operation var point = map.fromContainerPixelToLatLng(clickedPixel) map.setCenter(point); // hide the context menu now that it has been used contextmenu.style.visibility="hidden"; // coordinatesMapHere(); } function coordinatesMapHere() { // alert('1'); var point = map.fromContainerPixelToLatLng(clickedPixel); alert(point.lat() + ',' + point.lng()); $("mapcoordinates").innerHTML='Συντεταγμένες: '+point.lat() + '
' + point.lng(); contextmenu.style.visibility="hidden"; }