您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Displays the locality of the current location and provides links to open GIS if available
当前为
- // ==UserScript==
- // @name WME GIS
- // @author @Philistine11
- // @namespace https://greasyfork.org/en/users/53803
- // @description Displays the locality of the current location and provides links to open GIS if available
- // @include https://www.waze.com/editor/*
- // @version 1.3.2
- // ==/UserScript==
- function gis_init(model, modeId) {
- if (modeId === 1)
- return;
- var location = $('div.location-info-region');
- if (location.length === 0) {
- setTimeout(gis_init, 500);
- return;
- }
- location.after('<div class="btn-group btn-group-sm" style="float:left; margin-left:1rem;"><a id="locality_gis" class="btn btn-default disabled hidden" style="border:1px solid" target="_blank" href="#">Locality</a><a id="county_gis" class="btn btn-default disabled hidden" style="border:1px solid" target="_blank" href="#">County</a><a id="state_gis" class="btn btn-default disabled hidden" style="border:1px solid" target="_blank" href="#">State</a></div>');
- var states = {};
- $.getJSON('https://script.google.com/macros/s/AKfycbx2bytvT5Un0TWcaU7BpVkauqeE8zqt8Mek7Zq-OF-bznGYDyZw/exec?link=10dR8z16eKPHeI-ywLcHh2UNS3enQ7gt36Hhzm9nOJbA', function(rows) {
- for (var row in rows)
- states[rows[row][0]] = rows[row][1];
- });
- W.app.modeController.model.bind('change:mode', gis_init);
- W.map.events.register('moveend', null, function() {
- var center = W.map.getCenter().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
- $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng='+center.lat+','+center.lon, function(data) {
- if(data.status === "OK"){
- var locs = data.results[0].address_components;
- var locality = "", county = "", state = "";
- $('#locality_gis').addClass('hidden');
- $('#county_gis').addClass('hidden');
- $('#state_gis').addClass('hidden');
- for (var loc = 0; loc < locs.length; loc++) {
- if (locs[loc].types.indexOf("administrative_area_level_1") != -1) {
- state = locs[loc].long_name;
- $('#state_gis').removeClass('hidden').text(state);
- } else if (locs[loc].types.indexOf("administrative_area_level_2") != -1) {
- county = locs[loc].long_name;
- $('#county_gis').removeClass('hidden').text(county);
- } else if (locs[loc].types.indexOf("locality") != -1) {
- locality = locs[loc].long_name;
- $('#locality_gis').removeClass('hidden').text(locality);
- }
- }
- $('#locality_gis').prop('href', '#').addClass('disabled');
- $('#county_gis').prop('href', '#').addClass('disabled');
- $('#state_gis').prop('href', '#').addClass('disabled');
- if (states.hasOwnProperty(state)) {
- $.getJSON('https://script.google.com/macros/s/AKfycbx2bytvT5Un0TWcaU7BpVkauqeE8zqt8Mek7Zq-OF-bznGYDyZw/exec?v=1.3&link='+states[state], function(rows) {
- for (var row in rows)
- if (rows[row][2] !== "")
- if (rows[row][1] == "State") {
- $('#state_gis').prop('href', rows[row][2].replace('<lat>',center.lat).replace('<lon>',center.lon).replace('<zoom>',W.map.getZoom()+12)).removeClass('disabled');
- } else if (rows[row][1] == "County") {
- if (county.indexOf(rows[row][0]) != -1)
- $('#county_gis').prop('href', rows[row][2].replace('<lat>',center.lat).replace('<lon>',center.lon).replace('<zoom>',W.map.getZoom()+12)).removeClass('disabled');
- } else if (rows[row][0] == locality)
- $('#locality_gis').prop('href', rows[row][2].replace('<lat>',center.lat).replace('<lon>',center.lon).replace('<zoom>',W.map.getZoom()+12)).removeClass('disabled');
- });
- }
- }
- });
- });
- }
- gis_init();