2017-01-25 4 views
-1

を選択:Google MapsのAPI 3編集可能な形状が唯一の後、私は私の地図上のこれらの形状を持つ

Shapes editable: true

今、彼らはすべて私が非表示にしたいプロパティ

editable: true

を持っていますポリゴンを選択してそのポリゴンのみを表示した後にのみ表示します。

今、私のコードはこれです:

var b; 
b = new google.maps.Data(); 
b.addGeoJson('{ "type": "FeatureCollection", "features": 
    [{"type": "Feature","properties": {"id": "1051628","foglio": "","mappale": "", "position": {"lat": 43.546814276687, "lng": 10.337254370195}, "strokeColor": "#7ae7bf", "titolo": "zzzzzz", "fillColor": "#7ae7bf", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.332469940185,43.549263513592],[10.331954956054,43.545499778244],[10.337319374083,43.544131088941],[10.342426300048,43.544846544045],[10.342426300048,43.548299273208],[10.337877273559,43.549216857155],[10.332469940185,43.549263513592]]]}}, 
    {"type": "Feature","properties": {"id": "1051627","foglio": "","mappale": "", "position": {"lat": 43.54024526634, "lng": 10.337116288813}, "strokeColor": "#a4bdfc", "titolo": "ccccc", "fillColor": "#a4bdfc", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.334143638611,43.542015780715],[10.332856178284,43.539682634096],[10.337061882019,43.537878272135],[10.340623855591,43.538562691649],[10.340065956116,43.542420183614],[10.334143638611,43.542015780715]]]}}, 
    {"type": "Feature","properties": {"id": "1051629","foglio": "","mappale": "", "position": {"lat": 43.554260451384, "lng": 10.342584492726}, "strokeColor": "#5484ed", "titolo": "ZONA X", "fillColor": "#5484ed", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.339808464051,43.55616826814],[10.336675643921,43.554053382324],[10.3386926651,43.551907319379],[10.346717834472,43.55221834773],[10.34710407257,43.553897873085],[10.347490310669,43.556634777078],[10.343885421753,43.556728078432],[10.339808464051,43.55616826814]]]}}, 
    {"type": "Feature","properties": {"id": "1051630","foglio": "","mappale": "", "position": {"lat": 43.560583281587, "lng": 10.328228294878}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.325603485108,43.562947842858],[10.325260162354,43.558936168313],[10.330967903138,43.558811771033],[10.33109664917,43.561081980949],[10.331268310547,43.562854551135],[10.328564643861,43.56161064769],[10.325603485108,43.562947842858]]]}}, 
    {"type": "Feature","properties": {"id": "1051631","foglio": "","mappale": "", "position": {"lat": 43.560832847243, "lng": 10.339087906847}, "strokeColor": "#7ae7bf", "titolo": "aaaa", "fillColor": "#7ae7bf", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.340452194214,43.562450285332],[10.342168807984,43.558780671674],[10.336546897888,43.560024633548],[10.336546897888,43.562450285332],[10.340452194214,43.562450285332]]]}}, 
    {"type": "Feature","properties": {"id": "1051632","foglio": "","mappale": "", "position": {"lat": 43.55341577872849, "lng": 10.331590175628662}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.333499908447,43.554675415269],[10.333499908447,43.552156142188],[10.32968044281,43.552156142188],[10.32968044281,43.554675415269],[10.333499908447,43.554675415269]]]}}, 
    {"type": "Feature","properties": {"id": "1051643","foglio": "","mappale": "", "position": {"lat": 43.54352391806551, "lng": 10.349164604995167}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.352941153978,43.547801163757],[10.352941153978,43.539246672374],[10.345388056012,43.539246672374],[10.345388056012,43.547801163757],[10.352941153978,43.547801163757]]]}}, 
    {"type": "Feature","properties": {"id": "1051635","foglio": "","mappale": "", "position": {"lat": 43.544971044693, "lng": 10.326461808874}, "strokeColor": "#ffb878", "titolo": "cerchietto", "fillColor": "#ffb878", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.326461791992,43.546576818809],[10.327764041441,43.546270121615],[10.328568847797,43.545467185331],[10.328568813107,43.54447471628],[10.327763985312,43.543671803909],[10.326461791992,43.543365121496],[10.325159598672,43.543671803909],[10.324354770877,43.54447471628],[10.324354736187,43.545467185331],[10.325159542542,43.546270121615],[10.326461791992,43.546576818809]]]}}, 
    {"type": "Feature","properties": {"id": "1051640","foglio": "","mappale": "", "position": {"lat": 43.552140590792334, "lng": 10.324230194091797}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.324230194092,43.552829084238],[10.324788581599,43.552697592332],[10.325133678896,43.55235334341],[10.325133672517,43.55192783106],[10.324788571277,43.551583586536],[10.324230194092,43.551452097347],[10.323671816906,43.551583586536],[10.323326715666,43.55192783106],[10.323326709287,43.55235334341],[10.323671806585,43.552697592332],[10.324230194092,43.552829084238]]]}}, 
    {"type": "Feature","properties": {"id": "1051641","foglio": "","mappale": "", "position": {"lat": 43.54192245596135, "lng": 10.309167058999265}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.309167058999,43.545323508975],[10.31192504128,43.544673932503],[10.31362944219,43.542973352369],[10.313629286612,43.540871386013],[10.311924789549,43.539170913133],[10.309167058999,43.538521402948],[10.30640932845,43.539170913133],[10.304704831386,43.540871386013],[10.304704675808,43.542973352369],[10.306409076719,43.544673932503],[10.309167058999,43.545323508975]]]}}, 
    {"type": "Feature","properties": {"id": "1051642","foglio": "","mappale": "", "position": {"lat": 43.54291747554173, "lng": 10.313716531964019}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.313716531964,43.544032588857],[10.314620786961,43.543819617602],[10.315179633751,43.543262055179],[10.315179617026,43.542572877248],[10.314620759898,43.542015326356],[10.313716531964,43.541802362226],[10.31281230403,43.542015326356],[10.312253446902,43.542572877248],[10.312253430177,43.543262055179],[10.312812276967,43.543819617602],[10.313716531964,43.544032588857]]]}}, 
    {"type": "Feature","properties": {"id": "1051639","foglio": "","mappale": "", "position": {"lat": 43.532153844498, "lng": 10.405873600363}, "strokeColor": "#dc2127", "titolo": "", "fillColor": "#dc2127", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.403366088867,43.559597356045],[10.42363093806,43.554823716208],[10.436148509791,43.542327954279],[10.436140118755,43.526885919287],[10.423617361075,43.514395941088],[10.403366088867,43.50962587579],[10.383114816658,43.514395941088],[10.370592058978,43.526885919287],[10.370583667942,43.542327954279],[10.397864118091,43.539146566809],[10.403366088867,43.559597356045]]]}}, 
    {"type": "Feature","properties": {"id": "1051644","foglio": "","mappale": "", "position": {"lat": 43.5486250369669, "lng": 10.340603289805586}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.362941023777,43.553399378983],[10.362941023777,43.543850694951],[10.318265555834,43.543850694951],[10.318265555834,43.553399378983],[10.362941023777,43.553399378983]]]}}]}'); 
b.setStyle(function(feature){ 
    return { strokeColor: col, 
    strokeWeight: 1, 
    fillOpacity: 0.3, 
    fillColor: col, 
    clickable: true, 
    draggable: true, 
    editable: true, 
    } 
}); 
b.setMap(map); 

私は形状をクリックした後、一度に一つだけ形状のためeditable: trueを設定できますか?私は解決策を自分で見つけた

+0

? – Blauharley

+0

私は、編集可能なpolyongs頂点の周りの白い円を意味します。 これらのポリゴンを編集可能にするには、それらのポリゴンの1つをクリックした後で、一度に1つのポリゴンしかクリックしないといけません。 – kiks73

+0

問題を示す[mcve]を入力してください。図形を 'editable:false'に設定し、図形を' editable:true'に設定するコードを書いて、それらを選択すると(クリックすると)、おそらくあなたは図形を 'editable:false'に設定したいでしょう。 – geocodezip

答えて

0

私はその後、私はクリックイベントにスタイルを上書きeditable: false

b.setStyle(function(feature){ 
    return { strokeColor: col, 
    strokeWeight: 1, 
    fillOpacity: 0.3, 
    fillColor: col, 
    clickable: true, 
    draggable: true, 
    editable: false, 
    } 
}); 

にデフォルトのスタイルを設定しました。これは、クリックされた機能に適用されます。

b.addListener('click', function(event) { 
        b.revertStyle(); 
        b.overrideStyle(event.feature, {editable: true}); 
       }); 

b.revertStyleコマンドは、すべての機能のデフォルトスタイルにスタイルを元に戻し、その新機能をクリックした後、最後にクリックを編集することはできませんに設定されています。

これは完全なコードです:あなたはハイライト化頂点(ポイント)とはどういう意味ですか

var b; 
b = new google.maps.Data(); 
b.addGeoJson('{ "type": "FeatureCollection", "features": 
    [{"type": "Feature","properties": {"id": "1051628","foglio": "","mappale": "", "position": {"lat": 43.546814276687, "lng": 10.337254370195}, "strokeColor": "#7ae7bf", "titolo": "zzzzzz", "fillColor": "#7ae7bf", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.332469940185,43.549263513592],[10.331954956054,43.545499778244],[10.337319374083,43.544131088941],[10.342426300048,43.544846544045],[10.342426300048,43.548299273208],[10.337877273559,43.549216857155],[10.332469940185,43.549263513592]]]}}, 
    {"type": "Feature","properties": {"id": "1051627","foglio": "","mappale": "", "position": {"lat": 43.54024526634, "lng": 10.337116288813}, "strokeColor": "#a4bdfc", "titolo": "ccccc", "fillColor": "#a4bdfc", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.334143638611,43.542015780715],[10.332856178284,43.539682634096],[10.337061882019,43.537878272135],[10.340623855591,43.538562691649],[10.340065956116,43.542420183614],[10.334143638611,43.542015780715]]]}}, 
    {"type": "Feature","properties": {"id": "1051629","foglio": "","mappale": "", "position": {"lat": 43.554260451384, "lng": 10.342584492726}, "strokeColor": "#5484ed", "titolo": "ZONA X", "fillColor": "#5484ed", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.339808464051,43.55616826814],[10.336675643921,43.554053382324],[10.3386926651,43.551907319379],[10.346717834472,43.55221834773],[10.34710407257,43.553897873085],[10.347490310669,43.556634777078],[10.343885421753,43.556728078432],[10.339808464051,43.55616826814]]]}}, 
    {"type": "Feature","properties": {"id": "1051630","foglio": "","mappale": "", "position": {"lat": 43.560583281587, "lng": 10.328228294878}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.325603485108,43.562947842858],[10.325260162354,43.558936168313],[10.330967903138,43.558811771033],[10.33109664917,43.561081980949],[10.331268310547,43.562854551135],[10.328564643861,43.56161064769],[10.325603485108,43.562947842858]]]}}, 
    {"type": "Feature","properties": {"id": "1051631","foglio": "","mappale": "", "position": {"lat": 43.560832847243, "lng": 10.339087906847}, "strokeColor": "#7ae7bf", "titolo": "aaaa", "fillColor": "#7ae7bf", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.340452194214,43.562450285332],[10.342168807984,43.558780671674],[10.336546897888,43.560024633548],[10.336546897888,43.562450285332],[10.340452194214,43.562450285332]]]}}, 
    {"type": "Feature","properties": {"id": "1051632","foglio": "","mappale": "", "position": {"lat": 43.55341577872849, "lng": 10.331590175628662}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.333499908447,43.554675415269],[10.333499908447,43.552156142188],[10.32968044281,43.552156142188],[10.32968044281,43.554675415269],[10.333499908447,43.554675415269]]]}}, 
    {"type": "Feature","properties": {"id": "1051643","foglio": "","mappale": "", "position": {"lat": 43.54352391806551, "lng": 10.349164604995167}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.352941153978,43.547801163757],[10.352941153978,43.539246672374],[10.345388056012,43.539246672374],[10.345388056012,43.547801163757],[10.352941153978,43.547801163757]]]}}, 
    {"type": "Feature","properties": {"id": "1051635","foglio": "","mappale": "", "position": {"lat": 43.544971044693, "lng": 10.326461808874}, "strokeColor": "#ffb878", "titolo": "cerchietto", "fillColor": "#ffb878", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.326461791992,43.546576818809],[10.327764041441,43.546270121615],[10.328568847797,43.545467185331],[10.328568813107,43.54447471628],[10.327763985312,43.543671803909],[10.326461791992,43.543365121496],[10.325159598672,43.543671803909],[10.324354770877,43.54447471628],[10.324354736187,43.545467185331],[10.325159542542,43.546270121615],[10.326461791992,43.546576818809]]]}}, 
    {"type": "Feature","properties": {"id": "1051640","foglio": "","mappale": "", "position": {"lat": 43.552140590792334, "lng": 10.324230194091797}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.324230194092,43.552829084238],[10.324788581599,43.552697592332],[10.325133678896,43.55235334341],[10.325133672517,43.55192783106],[10.324788571277,43.551583586536],[10.324230194092,43.551452097347],[10.323671816906,43.551583586536],[10.323326715666,43.55192783106],[10.323326709287,43.55235334341],[10.323671806585,43.552697592332],[10.324230194092,43.552829084238]]]}}, 
    {"type": "Feature","properties": {"id": "1051641","foglio": "","mappale": "", "position": {"lat": 43.54192245596135, "lng": 10.309167058999265}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.309167058999,43.545323508975],[10.31192504128,43.544673932503],[10.31362944219,43.542973352369],[10.313629286612,43.540871386013],[10.311924789549,43.539170913133],[10.309167058999,43.538521402948],[10.30640932845,43.539170913133],[10.304704831386,43.540871386013],[10.304704675808,43.542973352369],[10.306409076719,43.544673932503],[10.309167058999,43.545323508975]]]}}, 
    {"type": "Feature","properties": {"id": "1051642","foglio": "","mappale": "", "position": {"lat": 43.54291747554173, "lng": 10.313716531964019}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.313716531964,43.544032588857],[10.314620786961,43.543819617602],[10.315179633751,43.543262055179],[10.315179617026,43.542572877248],[10.314620759898,43.542015326356],[10.313716531964,43.541802362226],[10.31281230403,43.542015326356],[10.312253446902,43.542572877248],[10.312253430177,43.543262055179],[10.312812276967,43.543819617602],[10.313716531964,43.544032588857]]]}}, 
    {"type": "Feature","properties": {"id": "1051639","foglio": "","mappale": "", "position": {"lat": 43.532153844498, "lng": 10.405873600363}, "strokeColor": "#dc2127", "titolo": "", "fillColor": "#dc2127", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.403366088867,43.559597356045],[10.42363093806,43.554823716208],[10.436148509791,43.542327954279],[10.436140118755,43.526885919287],[10.423617361075,43.514395941088],[10.403366088867,43.50962587579],[10.383114816658,43.514395941088],[10.370592058978,43.526885919287],[10.370583667942,43.542327954279],[10.397864118091,43.539146566809],[10.403366088867,43.559597356045]]]}}, 
    {"type": "Feature","properties": {"id": "1051644","foglio": "","mappale": "", "position": {"lat": 43.5486250369669, "lng": 10.340603289805586}, "strokeColor": "#000000", "titolo": "", "fillColor": "#000000", "livello": "Lampioni", "sublivello": "Lampioni" },"geometry":{"type":"Polygon","coordinates":[[[10.362941023777,43.553399378983],[10.362941023777,43.543850694951],[10.318265555834,43.543850694951],[10.318265555834,43.553399378983],[10.362941023777,43.553399378983]]]}}]}'); 
b.setStyle(function(feature){ 
    return { strokeColor: col, 
    strokeWeight: 1, 
    fillOpacity: 0.3, 
    fillColor: col, 
    clickable: true, 
    draggable: true, 
    editable: false, 
    } 
}); 
b.setMap(map); 

b.addListener('click', function(event) { 
        b.revertStyle(); 
        b.overrideStyle(event.feature, {editable: true}); 
       }); 
関連する問題