Reputation: 2370
I am loading a data layer via calling a geoJSON file. I am drawing around 100+ polygons using the geoJSON file. I am setting the style via my js code, but the issue is that when the map loads the polygons it shows the strokes/fill colors with some default black shades for some milli seconds and then apply my color schemes correctly. Is there any way I can avoid this effect?
zipLayer = new google.maps.Data({
map: map1,
style: {
strokeColor: '#ff0000',
strokeOpacity:.8,
strokeWeight:1,
fillColor: '#ff0000',
fillOpacity:.1
}
});
var url = 'url/to/polygons';
$.ajax({
url: url,
success:function(data) {
zipLayer.addGeoJson(data);
}
});
Upvotes: 1
Views: 1366
Reputation: 161324
Use the map.data.loadGeoJson
method.
zipLayer = new google.maps.Data({
map: map1,
style: {
strokeColor: '#ff0000',
strokeOpacity:.8,
strokeWeight:1,
fillColor: '#ff0000',
fillOpacity:.1
}
});
zipLayer.addGeoJson('url/to/polygons);
Upvotes: 1