// ==UserScript== // @id iitc-plugin-portal-location // @name IITC-ja plugin: Portal Location // @author nmmr // @category Layer // @version 0.0.6 // @namespace https://github.com/nmmr/iitc-plugins // @updateURL https://github.com/nmmr/iitc-plugins/raw/master/js/portal-location.user.js // @downloadURL https://github.com/nmmr/iitc-plugins/raw/master/js/portal-location.user.js // @description Show portal locations on the map. // @include https://intel.ingress.com/intel* // @include http://intel.ingress.com/intel* // @match https://intel.ingress.com/intel* // @match http://intel.ingress.com/intel* // @include https://intel.ingress.com/mission/* // @include http://intel.ingress.com/mission/* // @match https://intel.ingress.com/mission/* // @match http://intel.ingress.com/mission/* // @require https://raw.githubusercontent.com/hunterjm/s2-geometry.js/master/src/s2geometry.js // @grant none // ==/UserScript== // TODO 候補用の配列、描画、ポータルデテールで名称説明ストビュー表示、ストビューリンク function wrapper(plugin_info) { // ensure plugin framework is there, even if iitc is not yet loaded if(typeof window.plugin !== 'function') window.plugin = function() {}; //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! //(leaving them in place might break the 'About IITC' page or break update checks) plugin_info.buildName = 'portal-locations'; plugin_info.dateTimeVersion = '20181113'; plugin_info.pluginId = 'portal-locations'; //END PLUGIN AUTHORS NOTE // PLUGIN START //////////////////////////////////////////////////////// class Portal { constructor(json) { this.lat = json.lat; this.lng = json.lng; this.latLng = L.latLng(this.lat, this.lng); this.latLngStr = this.lat + ',' + this.lng; this.date = (json.date == null) ? Date.now() : json.date; this.name = (json.name == null) ? '' : json.name; this.description = (json.description == null) ? '' : json.description; this.candidate = (json.candidate == null) ? false : json.candidate; this.sponsored = this.name.search(/ローソン|Lawson|ソフトバンク|Softbank|ワイモバイル|Y\!mobile/) != -1; this.guid = json.guid; } isNew() { return (Date.now() - this.date) < (1000 * 60 * 60 * 24 * 3); } draw(layer) { let property = {color: 'orange', weight: 3, opacity: 1, clickable: true, fill:true, fillOpacity:0.1}; if (this.isNew()) { property = {color: 'red', weight: 3, opacity: 1, clickable: true, fill:true, fillOpacity:0.1}; } if (map.getZoom() > 14 || this.isNew()) { let circle = L.circle([this.lat,this.lng], 20, property); let center = L.circle([this.lat,this.lng], 1, property); let guid = this.guid; center.on('click', () => { if (guid == null) { return null; } window.renderPortalDetails(guid); }); layer.addLayer(circle); layer.addLayer(center); } } } // use own namespace for plugin window.plugin.portalLocations = function() {}; window.plugin.portalLocations.storageKey = 'portallocations'; window.plugin.portalLocations.apiStorageKey = 'streetviewapi'; window.plugin.portalLocations.svApiKey = ''; window.plugin.portalLocations.cache = {}; window.plugin.portalLocations.cells = {}; window.plugin.portalLocations.portalLayer = null; window.plugin.portalLocations.s2CellLayer = null; //window.plugin.portalLocations.p2PCellLayer = null; window.plugin.portalLocations.cMode = null; window.plugin.portalLocations.setupCSS = function() { $("