From cc08aac1a0c2578e9d6a2f19cbf6b11dcd0aa23b Mon Sep 17 00:00:00 2001 From: geminiyellow Date: Thu, 25 Aug 2016 12:29:31 +0900 Subject: [PATCH 1/2] fix(map-chat): disable dummy info --- map-chat/javascript/map.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/map-chat/javascript/map.js b/map-chat/javascript/map.js index 7868964248..9e3ed35f3b 100644 --- a/map-chat/javascript/map.js +++ b/map-chat/javascript/map.js @@ -239,7 +239,7 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr, expir, pokenick) var expiration = expir; var pName = ''; if(typeof pokenick === 'undefined'){ - var pName = " just appeared!
lat: " + olat + " / long: " + olong; + var pName = " just appeared!
lat: " + olat + " / long: " + olong; } else { var pName = "" + pokenick + " just appeared!
lat: " + olat + " / long: " + olong; } @@ -320,9 +320,8 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr, expir, pokenick) } }); - if (msg.text) { + if (msg.text !== 'undefined') { infoWindow.open(map, marker); - } var timeoutId = setTimeout(function () { infoWindow.close() }, 10000); From 557027d057fe0d4de53f91cafd4c71dc5b44bb8a Mon Sep 17 00:00:00 2001 From: geminiyellow Date: Thu, 25 Aug 2016 13:41:50 +0900 Subject: [PATCH 2/2] fix(map-chat): fix pokemon icon scale --- map-chat/javascript/map.js | 131 +++++++++++++------------------------ 1 file changed, 45 insertions(+), 86 deletions(-) diff --git a/map-chat/javascript/map.js b/map-chat/javascript/map.js index 9e3ed35f3b..55ac5cc11f 100644 --- a/map-chat/javascript/map.js +++ b/map-chat/javascript/map.js @@ -45,7 +45,6 @@ function initialize() { scaledSize: new google.maps.Size(30, 30) }; - var mapOptions = { center: defaultLatLng, zoom: defaultZoom, // The initial zoom level when your map loads (0-20) @@ -135,6 +134,41 @@ function createMessage(text) { text: text }; } + +function setupMarkerAndInfoWindow(msgSessionId, content, position, map, icoOn, icoOff) { + var infoWindow = new google.maps.InfoWindow({ + content: content, + maxWidth: 400, + disableAutoPan: true, + zIndex: infoWindowZIndex + }); + infoWindowZIndex++; + + var marker = new google.maps.Marker({ + position: position, + map: map, + draggable: false, + icon: icoOn, + title: "Click to mute/un-mute User " + msgSessionId + }); + + marker.addListener('click', function () { + if (markersMap[msgSessionId].disabled) { + markersMap[msgSessionId].disabled = false; + marker.setIcon(icoOn); + } else { + markersMap[msgSessionId].disabled = true; + marker.setIcon(icoOff); + infoWindow.close(); + } + }); + + return { + marker: marker, + infoWindow: infoWindow + }; +} + function displayChatMessageOnMap(raw) { var msg = JSON.parse(raw) //console.log(msg) @@ -170,39 +204,15 @@ function displayChatMessageOnMap(raw) { if (existingTimeoutId) { clearTimeout(existingTimeoutId); } - markersMap[msgSessionId].timeoutId = - setTimeout(function () { existingInfoWindow.close() }, 10000); + markersMap[msgSessionId].timeoutId = setTimeout(function () { existingInfoWindow.close() }, 10000); existingInfoWindow.open(map, existingMarker); } } else { // new marker - var infoWindow = new google.maps.InfoWindow({ - content: msg.text, - maxWidth: 400, - disableAutoPan: true, - zIndex: infoWindowZIndex - }); - infoWindowZIndex++; - - var marker = new google.maps.Marker({ - position: newPosition, - map: map, - draggable: false, - icon: markerImage, - title: "Click to mute/un-mute User " + msgSessionId - }); - - marker.addListener('click', function () { - if (markersMap[msgSessionId].disabled) { - markersMap[msgSessionId].disabled = false; - marker.setIcon(markerImage); - } else { - markersMap[msgSessionId].disabled = true; - marker.setIcon(disabledMarkerImage); - infoWindow.close(); - } - }); + var markerWindow = setupMarkerAndInfoWindow(msgSessionId,msg.text, newPosition, map, markerImage, disabledMarkerImage); + var infoWindow = markerWindow.infoWindow; + var marker = markerWindow.marker; - if (msg.text) { + if (msg.text !== 'undefined') { infoWindow.open(map, marker); } @@ -231,7 +241,6 @@ function timeUntil(now, then) { return diff; } - function displayMessageOnMap(msg, olat, olong, sessid, icostr, expir, pokenick) { // @ro: passing values split from incoming payload into two variables for now (lat and long) var newPosition = new google.maps.LatLng(olat, olong); @@ -264,62 +273,12 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr, expir, pokenick) "$1" ); - if (markersMap[msgSessionId]) { // update existing marker - var infoWindow = new google.maps.InfoWindow({ - content: pName, - maxWidth: 400, - disableAutoPan: true, - zIndex: infoWindowZIndex - }); - infoWindowZIndex++; - - var marker = new google.maps.Marker({ - position: newPosition, - map: map, - draggable: false, - icon: icostr, - icon: { url: icostr, scaledSize: new google.maps.Size(60, 60) }, - title: "Click to mute/un-mute User " + msgSessionId - }); - - marker.addListener('click', function () { - if (markersMap[msgSessionId].disabled) { - markersMap[msgSessionId].disabled = false; - marker.setIcon(icostr); - } else { - markersMap[msgSessionId].disabled = true; - marker.setIcon(disabledMarkerImage); - infoWindow.close(); - } - }); - } else { // new marker - var infoWindow = new google.maps.InfoWindow({ - content: pName, - maxWidth: 400, - disableAutoPan: true, - zIndex: infoWindowZIndex - }); - infoWindowZIndex++; - - var marker = new google.maps.Marker({ - position: newPosition, - map: map, - draggable: false, - icon: { url: icostr, scaledSize: new google.maps.Size(60, 60) }, - title: "Click to mute/un-mute User " + msgSessionId - }); - - marker.addListener('click', function () { - if (markersMap[msgSessionId].disabled) { - markersMap[msgSessionId].disabled = false; - marker.setIcon(icostr); - } else { - markersMap[msgSessionId].disabled = true; - marker.setIcon(icostr); - infoWindow.close(); - } - }); + var icon = { url: icostr, scaledSize: new google.maps.Size(36, 36) }; + var markerMap = setupMarkerAndInfoWindow(msgSessionId, pName, newPosition, map, icon, icon); + var marker = markerMap.marker; + var infoWindow = markerMap.infoWindow; + if (!markersMap[msgSessionId]) { // new marker if (msg.text !== 'undefined') { infoWindow.open(map, marker); }