diff --git a/OsmAnd/assets/server/go.html b/OsmAnd/assets/server/go.html index c6668f2481..779e306932 100644 --- a/OsmAnd/assets/server/go.html +++ b/OsmAnd/assets/server/go.html @@ -44,6 +44,10 @@ return popupContent; } + function markerClick(e){ + + } + function setupMarkers(){ $.ajax({ type: 'GET', @@ -54,10 +58,7 @@ complete: function(r) { var points = JSON.parse(r.responseText); points.forEach(e => { - var point = {}; - point.lat = e.latitude; - point.lon = e.longitude; - window.goMap.map.addMarker(point); + window.goMap.map.addPopupMarker(e,markerClick); }); }, error: function(e) { @@ -65,8 +66,11 @@ } }); } - //TODO add document ready or map ready event - setTimeout(function(){ setupMarkers(); }, 4000); + + $( document ).ready(function() { + setupMarkers(); + }); + diff --git a/OsmAnd/assets/server/scripts/go.js b/OsmAnd/assets/server/scripts/go.js index 37ab40caab..3aeae4c269 100644 --- a/OsmAnd/assets/server/scripts/go.js +++ b/OsmAnd/assets/server/scripts/go.js @@ -18,8 +18,8 @@ var goMap = { 'config':{ 'containerid': 'gocontainer', 'defaults':{ - 'lat':51.505, - 'lon':-0.09, + 'lat':50.27, + 'lon':30.30, 'zoom':13 } }, @@ -82,6 +82,15 @@ var goMap = { } }; +function toColor(num) { + num >>>= 0; + var b = num & 0xFF, + g = (num & 0xFF00) >>> 8, + r = (num & 0xFF0000) >>> 16, + a = ( (num & 0xFF000000) >>> 24 ) / 255 ; + return "rgba(" + [r, g, b, a].join(",") + ")"; + } + (function($) { $.mapwidget = function(config) { var loc = goMap.point.lat + '/' + goMap.point.lon; @@ -107,12 +116,29 @@ var goMap = { }, addMarker:function(point){ L.marker([point.lat, point.lon]).addTo(mapobj.map); + }, + addPopupMarker:function(favorite,onClickEvent){ + window.point = favorite; + var point = {}; + point.lat = favorite.latitude; + point.lon = favorite.longitude; + var popup = L.popup().setContent( + "name: " + favorite.name + "
" + + "address: " + favorite.address + "
" + + "category: " + favorite.category); + L.marker([point.lat, point.lon]) + .bindPopup(popup) + .addTo(mapobj.map) + .on('click', function(e) { + onClickEvent(e); + }); } }; mapobj.init(); return { showPoint: mapobj.showPoint, - addMarker: mapobj.addMarker + addMarker: mapobj.addMarker, + addPopupMarker: mapobj.addPopupMarker }; }; })(jQuery);