1+ function UpdateGeoAxes(obj , geoIndex )
2+
3+ % -AXIS INDEX-%
4+ axIndex = obj .getAxisIndex(obj .State .Plot(geoIndex ).AssociatedAxis);
5+
6+ % -GET DATA STRUCTURE- %
7+ geoData = get(obj .State .Plot(geoIndex ).Handle);
8+
9+ % -CHECK FOR MULTIPLE AXES-%
10+ [xsource , ysource ] = findSourceAxis(obj ,axIndex );
11+
12+ % -------------------------------------------------------------------------%
13+
14+ % -set domain geo plot-%
15+ xo = geoData .Position(1 );
16+ yo = geoData .Position(2 );
17+ w = geoData .Position(3 );
18+ h = geoData .Position(4 );
19+
20+ geo.domain.x = min([xo xo + w ],1 );
21+ geo.domain.y = min([yo yo + h ],1 );
22+
23+ % -------------------------------------------------------------------------%
24+
25+ % -setting projection-%
26+ geo.projection.type = ' mercator' ;
27+
28+ % -------------------------------------------------------------------------%
29+
30+ % -setting basemap-%
31+ geo.framecolor = ' rgb(120,120,120)' ;
32+
33+ if strcmpi(geoData .Basemap , ' streets-light' )
34+ geo.oceancolor = ' rgba(20,220,220,1)' ;
35+ geo.landcolor = ' rgba(20,220,220,0.2)' ;
36+ elseif strcmpi(geoData .Basemap , ' colorterrain' )
37+ geo.oceancolor = ' rgba(118,165,225,0.6)' ;
38+ geo.landcolor = ' rgba(190,180,170,1)' ;
39+ geo.showcountries = true ;
40+ geo.showlakes = true ;
41+ end
42+
43+ geo.showocean = true ;
44+ geo.showcoastlines = false ;
45+ geo.showland = true ;
46+
47+ % -------------------------------------------------------------------------%
48+
49+ % -setting latitude axis-%
50+ latTick = geoData .LatitudeAxis .TickValues ;
51+
52+ geo.lataxis.range = geoData .LatitudeLimits ;
53+ geo.lataxis.tick0 = latTick(1 );
54+ geo.lataxis.dtick = mean(diff(latTick ));
55+
56+ if strcmpi(geoData .Grid , ' on' )
57+ geo.lataxis.showgrid = true ;
58+ geo.lataxis.gridwidth = geoData .LineWidth ;
59+ geo.lataxis.gridcolor = sprintf(' rgba(%f ,%f ,%f ,%f )' , 255 * geoData .GridColor , geoData .GridAlpha );
60+ end
61+
62+ % -------------------------------------------------------------------------%
63+
64+ % -setting longitude axis-%
65+ lonTick = geoData .LongitudeAxis .TickValues ;
66+
67+ geo.lonaxis.range = geoData .LongitudeLimits ;
68+ geo.lonaxis.tick0 = lonTick(1 );
69+ geo.lonaxis.dtick = mean(diff(lonTick ));
70+
71+ if strcmpi(geoData .Grid , ' on' )
72+ geo.lonaxis.showgrid = true ;
73+ geo.lonaxis.gridwidth = geoData .LineWidth ;
74+ geo.lonaxis.gridcolor = sprintf(' rgba(%f ,%f ,%f ,%f )' , 255 * geoData .GridColor , geoData .GridAlpha );
75+ end
76+
77+ % -------------------------------------------------------------------------%
78+
79+ % -set map center-%
80+ geo.center.lat = geoData .MapCenter(1 );
81+ geo.center.lon = geoData .MapCenter(2 );
82+
83+ % -------------------------------------------------------------------------%
84+
85+ % -set better resolution-%
86+ geo.resolution = ' 50' ;
87+
88+ % -------------------------------------------------------------------------%
89+
90+ % -set geo axes to layout-%
91+ obj.layout = setfield(obj .layout , sprintf(' geo%d ' , xsource + 1 ), geo );
92+
93+ % -------------------------------------------------------------------------%
94+
95+ % -TEXT STTINGS-%
96+ isText = false ;
97+ child = geoData .Children ;
98+ t = 1 ;
99+
100+ for n= 1 : length(child )
101+ if strcmpi(child(n ).Type, ' text' )
102+ isText = true ;
103+ texts{t } = child(t ).String;
104+ lats(t ) = child(t ).Position(1 );
105+ lons(t ) = child(t ).Position(2 );
106+ sizes(t ) = child(t ).FontSize;
107+ families{t } = matlab2plotlyfont(child(t ).FontName);
108+ colors{t } = sprintf(' rgb(%f ,%f ,%f )' , child(t ).Color);
109+
110+ if strcmpi(child(t ).HorizontalAlignment, ' left' )
111+ pos{t } = ' right' ;
112+ elseif strcmpi(child(t ).HorizontalAlignment, ' right' )
113+ pos{t } = ' left' ;
114+ else
115+ pos{t } = child(t ).HorizontalAlignment;
116+ end
117+
118+ t = t + 1 ;
119+ end
120+ end
121+
122+ if isText
123+ obj.data{geoIndex }.type = ' scattergeo' ;
124+ obj.data{geoIndex }.mode = ' text' ;
125+ obj.data{geoIndex }.text = texts ;
126+ obj.data{geoIndex }.lat = lats ;
127+ obj.data{geoIndex }.lon = lons ;
128+ obj.data{geoIndex }.geo = obj.data{geoIndex - 1 }.geo;
129+
130+ obj.data{geoIndex }.textfont.size = sizes ;
131+ obj.data{geoIndex }.textfont.color = colors ;
132+ obj.data{geoIndex }.textfont.family = families ;
133+ obj.data{geoIndex }.textposition = pos ;
134+ end
135+ end
0 commit comments